Ticket Hash: | 009ea91ce947192645d5995bc46a97fcfbd06d37 | ||
Title: | SQLiteDataAdapter.FillSchema problem with left joined tables | ||
Status: | Pending | Type: | Incident |
Severity: | Important | Priority: | Medium |
Subsystem: | Data_Reader | Resolution: | Under_Review |
Last Modified: |
2022-01-27 05:56:13 3.29 years ago |
Created: |
2022-01-26 05:57:38 3.30 years ago |
Version Found In: | 1.0.115.5 |
User Comments: | ||||||||||||||||||||||||||||||||||
anonymous added on 2022-01-26 05:57:38:
Hi all, I'm using SQLiteDataAdapter for a new project and maybe considered a bug or not well designed feature. If using SQLiteDataAdapter in conjunction with LEFT JOINS and it may be possible that missing child rows cause a ConstraintExcpetion on Fill method, if the child table contains not null columns. SQLiteDataAdapter seems to fill the AllowDbNull properties of the child table columns and set them to false which causes this exception. But left join expressions always can have Null values also in not null columns! I postet my code below to show the behavior. Regards, Stefan
mistachkin added on 2022-01-26 21:10:29: According to the code, a column marked "PRIMARY KEY" cannot be NULL. To quote from section 3.5 of "https://sqlite.org/lang_createtable.html": "According to the SQL standard, PRIMARY KEY should always imply NOT NULL. Unfortunately, due to a bug in some early versions, this is not the case in SQLite." For the functionality specific to System.Data.SQLite, has disallowed NULL for "PRIMARY KEY" columns for quite a while. anonymous added on 2022-01-27 05:56:13: Hi, But the CHILD Table is correctly filled with all NOT NULL Columns. The null values came from the LEFT JOIN due to the fact that HEAD_ID=2 has no child rows. The returning result set looks like this:
which is correct! The Schema of the DataTable created with FillSchema is not! The CHILD_ID and the HEAD_ID1 (CHILD.HEAD_ID) columns are set to AllowDbNull=false because they are NOT NULL in the database. BUT they are nullable for the schema returned by the LEFT JOIN Statement! And The FillSchema method needs to return the Schema for the applied SQL-Statement not the underlying tables. |