Strange UNIQUE INDEX Issue #216
tartufella
started this conversation in
General
Replies: 3 comments 9 replies
-
Can you format your code? It's hard to read. |
Beta Was this translation helpful? Give feedback.
1 reply
-
Do you get the same behavior if you repeat the same steps from the CLI? |
Beta Was this translation helpful? Give feedback.
3 replies
-
I downloaded your database, dropped the index and tried to add it from .NET: What does your process look like? Do you first insert the data and then create an index? Are you doing it from multiple threads, by any chance? Or do you execute it inside a transaction? |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi There, I have noticed in v1.1.0 that the CREATE UNIQUE INDEX no longer works.
The attached file was created using v1.1.0, previously updated from 1.0.2
In my .NET code I have this line :
duck.Execute("CREATE UNIQUE INDEX sales_idx ON Sales (CalendarID,ItemID,CountryID,ChannelDemandID,PriceType);");
The attached file was created by the .NET client v1.1.0;
If you then open the file in a duckdb cli you can see the following behavior:
If you run the following you will see duplicates :
SELECT * FROM Sales WHERE CalendarID = 202526 AND ItemID = 550
However if you also run :
INSERT INTO Sales (CalendarID,itemID,CountryID,ChannelDemandID,PriceType) VALUES (202526,550,1,9,'PROMO')
you will see an error as expected.
If you run :
SELECT index_name,table_name,is_unique,expressions,sql FROM duckdb_indexes
You can see that the index does exist and it's unique, so I'm not sure how the .NET client created this file with a unique index but then also allowed duplicates into the table without throwing an error. If I run the exact same code but with v1.0.2 then the .NET code will throw an error as expected when a duplicate is added.
I'm not sure I understand why there are both duplicates in the database but I also cannot add a duplicate!
9cfb53b4-faec-4640-a783-d4c9a27ddf94.zip
Many thanks
Beta Was this translation helpful? Give feedback.
All reactions