SQLite.Net-PCL
SQLite.Net-PCL copied to clipboard
Support for composite primary keys
Code changes to enable composite primary keys.
It was mentioned here. https://github.com/oysteinkrog/SQLite.Net-PCL/issues/72
I think it would be really good to have this supported. I was only able to run tests under Generic, Win32 and WindowsPhone8, others wouldn't build for some reason, I'll have to investigate.
Let me know what you think!
EDIT: I see AppVeyor build failed for some reason, but I don't think it's because of my code.
Would it be better to keep the current methods for if there is only one column of primary key. Also why have you only changed the delete methods to accept multiple primary keys a and missed out the get methods?
I'll gladly fix if I missed anything, could you point to exact methods?
Delete was the only one with changed signature as there is an overload which allows deleting based on the primary key. But maybe it would be worthwhile to keep the old one too, so if someone is using only single attribute keys they can keep using the old Delete call, without creating a dictionary every time.
Creating the table should behave the same if there's a single attribute key, allowing for autoincrement to be set.
Maybe I also should have left the name "PK" instead of changing it to "PKs" as technically there's always only one primary key (even if it spans over multiple columns).
There are two "Find" methods that you would need to change also a "Get" method all on SQLiteConnection
Good point. I changed those 2 methods, and also Delete method to take object again as parameter to not break any calls with only a single column primary key.
Also TableMapping is at the moment part of the publicAPI, so it may not be a good idea to remove a property like you have, maybe it would be better to provide both properties and have PK throw an exception if there is a composite primary key so that current users of the library can still use the Property if they are not using composite primary keys.
You mean, have both PK and PKs? Hmm.
Yeah that would probably be better than breaking the code of people who are using the library.
Yeah, both options are kind of bad, but breaking change is probably worse. :) I'll do it that way then.
I pushed the changes we discussed.
This sounds nice, I'll review/merge when I've got the current prerelease/beta out the door.
Any news on this?
I'm sorry but I don't have any time to spend on this project at the moment.
Any word on this? Just ran into a situation where Composite Keys would be really nice to have :)
It's already done here with latests paracleum updates: https://github.com/softlion/SQLite.Net-PCL All test passed. + new tests for multiple keys and partial keys (select and delete). This is my own implementation started 20 months ago and used in multiple commercial apps.
It breaks the Delete(primary key), as it conflicts with the Delete<T>(object) and with Delete(primary keys[]).
Can we get an update? Would love to have this.
softlion, do you have your nuget for your fork? I couldn't find it.
Yes i have a private nuget server on internet. PM me your email and i grant you access.
Is this supported now?
Any news with this?? When it's going to be released?
Any news with this?? Is working in Xamarin Ios?