Primary Key

Jan 10, 2013 at 12:12 PM

When I create a table in one db (eg: GCA\Us) through the command 

New-Item GCA:\Us -value @{ACCOUNT="TEXT UNIQUE"; NOME="TEXT NOT NULL"; DISABILITATO="TEXT NOT NULL"}

automatically creates _id as INTEGER PRIMARY KEY

I want to use ACCOUNT as primary key, but using 

New-Item GCA:\Us -value @{ACCOUNT="TEXT UNIQUE PRIMARY KEY" ... 

it replies 

New-Item : SQLite errortable "Us" has more than one primary keyIn riga:1 car:9+ New-Item <<<<  GCA:\Us1 -value @{ACCOUNT="TEXT UNIQUE PRIMARY KEY"; NOME="TEXT NOT NULL"; DISABILITATO="TEXT NOT NULL"}    + CategoryInfo          : NotSpecified: ([Data Source=C:\Temp\GCA.s3db]\Us1:String) [New-Item], SQLiteException    + FullyQualifiedErrorId : NewItem.Invoke,Microsoft.PowerShell.Commands.NewItemCommand

How I can bypass this problem?

Thnaks
Sergio

Jan 10, 2013 at 12:55 PM

I reply myself:

Invoke-Item GCA:\ -sql "CREATE TABLE [Users] ([ACCOUNT] TEXT PRIMARY KEY NOT NULL UNIQUE, [DISABILITATO] TEXT NOT NULL, [NOME] TEXT NOT NULL);"

Coordinator
Jan 11, 2013 at 3:42 PM

HA!  I was just  writing that same solution when I saw you beat me to it!

At the moment the provider assumes an integer primary key; there *was* a reason for this - I think it had to do with being able to reliably reference a key when you create a new record but I'm not sure now.  Create an issue so this doesn't get lost - I need to take another look at this and see if I can't unknot this assumption from the code.

Jan 11, 2013 at 10:10 PM

XD

Tnx a lot!

Sergio