ZeeZide / Enlighter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NULL values are being inserted when working with compound keys.

lutzmi opened this issue · comments

Hi,

when working with compound keys, NULL will be used as the value for the keys even though they were given. Executing the given sample project the resulting record in the database will be: NULL, NULL, First, Last, 22. I would have expected that the result would be 1, 2, First, Last, 22.

It seems that the generated insert SQL is ignoring the compound key:
/// SQL toINSERTa record into theperson` table.
public static let insert = #"INSERT INTO "person" ( "first_name", "last_name", "age" ) VALUES ( ?, ?, ? )"#

/// SQL to `INSERT` a record into the `person` table.
public static let insertReturning = #"INSERT INTO "person" ( "first_name", "last_name", "age" ) VALUES ( ?, ?, ? ) RETURNING "person_id", "another_id", "first_name", "last_name", "age""#`

Is there a way to work around that?

Thank you!

Probably a bug that needs to be fixed.

Thanks for the quick response :-)

While I've prepared everything to support compound keys, I really didn't test those. Quite likely that some things are wrong with those, tbh I didn't expect many people to use them ;-)

Quite likely it incorrectly detects those as automatic primary keys, maybe because they are INTs, ignoring the fact that they are compound keys.

Yep, using TEXT instead of INT seems to work as expected.
(You still may be right with your assumption as I am just one person ;-)