praeclarum / praeclarum/sqlite-net
multiple primary keys
Open
@praeclarum is already working on this.
Since Aug 13, 2017.
Feature
- Dominant language
- C#
- Stars
- 4.5k
- Forks
- 1.4k
- PR merge metrics
- No merged PRs in 30d
Description
In CreateTable, replace the code creating the string given to the Execute method by
var sbQuery = new StringBuilder("create table if not exists \"").Append(map.TableName).Append("\"(\n");
map.Columns.Aggregate(sbQuery, (sb, column) => sb.Append(Orm.SqlDecl(column, StoreDateTimeAsTicks)).Append(",\n"));
var pks = (from c in map.Columns where c.IsPK select c).ToList();
if (pks.Count != 0)
{
//, PRIMARY KEY (A_ID, B_ID)
sbQuery.Append("primary key (");
pks.Aggregate(sbQuery, (sb, c) => sb.Append(c.Name).Append(','));
sbQuery.Remove(sbQuery.Length - 1, 1).Append(')');
}
else
{
sbQuery.Remove(sbQuery.Length - 3, 3);
}
sbQuery.Append(")");
var count = Execute(sbQuery.ToString());
And in the SqlDecl method, remove the line
decl += "primary key ";
Also in MigrateTable add a not supported exception:
foreach (var p in toBeAdded)
{
if (p.IsPK)
throw new Exception("New columns can not be primary keys (unsupported migration)");
var addCol = "alter table \"" + map.TableName + "\" add column " + Orm.SqlDecl(p, StoreDateTimeAsTicks);
Execute(addCol);
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.