System.Data.SQLite

Login
This project makes use of Eagle, provided by Mistachkin Systems.
Eagle: Secure Software Automation
2011-11-13
21:33
Remove unnecessary using statement from test case for ticket [7e3fa93744]. check-in: c86034a5fb user: mistachkin tags: trunk
06:25 Ticket [7e3fa93744] Problem with 3 table query! status still Closed with 1 other change artifact: fac8fa62b5 user: mistachkin
06:24
Merge fix for ticket [7e3fa93744] and several unit test infrastructure enhancements to trunk. check-in: 8fe2a401d6 user: mistachkin tags: trunk
06:00 Ticket [7e3fa93744] Problem with 3 table query! status still Closed with 2 other changes artifact: 775bbfaaf6 user: mistachkin
06:00 Closed ticket [7e3fa93744]. artifact: 1f6c8a0538 user: mistachkin
05:55
When generating the schema for the contents of a data reader, skip flagging columns as 'unique' if the data reader is holding the result of some kind of multi-table construct (i.e. a join) because we must allow duplicate values in that case. Fix for ticket [7e3fa93744]. Also, enhance vendor-specific initialization file for Eagle to report any test setting overrides being used. Closed-Leaf check-in: da3e0bfb53 user: mistachkin tags: tkt-7e3fa93744
2011-11-12
08:38
Work on minimal test cases for ticket [7e3fa93744]. check-in: c243b1a500 user: mistachkin tags: tkt-7e3fa93744
06:47 Ticket [7e3fa93744] Problem with 3 table query! status still Open with 1 other change artifact: 91bcd20e7d user: mistachkin
2011-10-28
14:33 Ticket [7e3fa93744]: 1 change artifact: e11cc57264 user: mistachkin
09:35 Ticket [7e3fa93744]: 1 change artifact: 4659d91652 user: anonymous
09:34 Ticket [7e3fa93744]: 1 change artifact: d44228b83f user: anonymous
08:57 Ticket [7e3fa93744]: 1 change artifact: 90f961b359 user: anonymous
08:56 Open ticket [7e3fa93744]. artifact: 5f660510b5 user: anonymous
2011-10-26
14:37 Closed ticket [7e3fa93744]. artifact: 0f13de08d2 user: mistachkin
14:02 Ticket [7e3fa93744]: 1 change artifact: a9ce94e4b3 user: mistachkin
12:47 Ticket [7e3fa93744]: 1 change artifact: 009f42e32a user: anonymous
12:46 Ticket [7e3fa93744]: 1 change artifact: fb566a740d user: anonymous
12:35 Ticket [7e3fa93744]: 1 change artifact: 037d206b95 user: anonymous
10:35 Ticket [7e3fa93744]: 1 change artifact: fb23d9acc7 user: anonymous
10:33 Ticket [7e3fa93744]: 4 changes artifact: 78436728ea user: anonymous
09:32 New ticket [7e3fa93744]. artifact: cf0332eea3 user: anonymous

Ticket Hash: 7e3fa93744b9e2949a09a80ccbe463725b2aa8e8
Title: Problem with 3 table query!
Status: Closed Type: Code_Defect
Severity: Severe Priority: Immediate
Subsystem: Data_Reader Resolution: Fixed
Last Modified: 2011-11-13 06:25:30
Version Found In: 1.0.66.0 and 1.0.76.0
Description:
Table "GunsAndAmmo"

p GunID integer prim autoinvrement GunManufactor text, GunModel text, Division text, Factor text,

Table "Shooters"

ShooterInternalID integer prim autoincrement, DataBirth integer, LastName text, FirstName text,

Table "ShooterGun"

ShooterID integer prim not null, GunID integer prim not null,

The main quary im havin problems with are:

"Select Shooters.FirstName, Shooters.LastName, ShooterGun.ShooterID, GunsAndAmmo.Division, GunsAndAmmo.Factor, GunsAndAmmo.GunManufactor, GunsAndAmmo.GunModel from Shooters, ShooterGun, GunsAndAmmo"

This shoudl return about 24 results currently but are only returning 3. If I remove "ShooterGun.ShooterID" from the query then i get the correct number of results but no. The same happens if I use "Shooters.ShooterInternalID" insted of "ShooterGun.ShooterID".

This is not a problem when using a different client tool.


anonymous added on 2011-10-26 10:33:53 UTC:
Use:
SQLiteConnection cnn = new SQLiteConnection(dbConnection);
cnn.Open();
SQLiteCommand mycommand = new SQLiteCommand(cnn);
mycommand.CommandText = sql;
SQLiteDataReader reader = mycommand.ExecuteReader();
dt.Load(reader);
reader.Close();
cnn.Close();


anonymous added on 2011-10-26 12:35:07 UTC:
Problem seems to exist in 1.0.76.0 also


anonymous added on 2011-10-26 12:46:02 UTC:
values in tabels:
"GunsAndAmmo"
2, CZ, SP-01 Shaddow, Open
3, CZ, 75, Production

Table "Shooters"
1, 19800506, Aanonsen, Eirik
2, , Westol, Stein

Table "ShooterGun"
1, 3
1, 2
2, 2
2, 3


anonymous added on 2011-10-26 12:47:12 UTC:
Forgot one entry ( for making it 24 as the expected result)
3, , Eiriksa, Aasuhds


mistachkin added on 2011-10-26 14:02:31 UTC:

Have you tried using the latest System.Data.SQLite?  Version 1.0.66.0 was
released in April 2010 and quite a few things have been changed and/or fixed
since then.

Also, is the following SQL what you are doing?

CREATE TABLE GunsAndAmmo (
  GunID INTEGER PRIMARY KEY AUTOINCREMENT,
  GunManufactor TEXT,
  GunModel TEXT,
  Division TEXT,
  Factor TEXT
);

CREATE TABLE Shooters (
  ShooterInternalID INTEGER PRIMARY KEY AUTOINCREMENT,
  DataBirth INTEGER,
  LastName TEXT,
  FirstName TEXT
);

CREATE TABLE ShooterGun (
  ShooterID INTEGER NOT NULL,
  GunID INTEGER NOT NULL
);

SELECT Shooters.FirstName, Shooters.LastName,
       ShooterGun.ShooterID, GunsAndAmmo.Division,
       GunsAndAmmo.Factor, GunsAndAmmo.GunManufactor,
       GunsAndAmmo.GunModel
FROM Shooters, ShooterGun, GunsAndAmmo;


INSERT INTO GunsAndAmmo (GunID, GunManufactor, GunModel, Division, Factor)
VALUES(2, 'CZ', 'SP-01', 'Shaddow', 'Open');

INSERT INTO GunsAndAmmo (GunID, GunManufactor, GunModel, Division, Factor)
VALUES(3, 'CZ', 75, NULL, 'Production');

INSERT INTO Shooters (ShooterInternalID, DataBirth, LastName, FirstName)
VALUES(1, 19800506, 'Aanonsen', 'Eirik');

INSERT INTO Shooters (ShooterInternalID, DataBirth, LastName, FirstName)
VALUES(2, NULL, 'Westol', 'Stein');

INSERT INTO Shooters (ShooterInternalID, DataBirth, LastName, FirstName)
VALUES(3, NULL, 'Eiriksa', 'Aasuhds');

INSERT INTO ShooterGun (ShooterID, GunID) VALUES(1, 3);
INSERT INTO ShooterGun (ShooterID, GunID) VALUES(1, 2);
INSERT INTO ShooterGun (ShooterID, GunID) VALUES(2, 2);
INSERT INTO ShooterGun (ShooterID, GunID) VALUES(2, 3);

mistachkin added on 2011-10-26 14:37:49 UTC:
I'm not able to reproduce this issue with either version of System.Data.SQLite. If you can provide more specific steps to get this issue to reproduce with the latest version of System.Data.SQLite, please re-open this ticket.


anonymous added on 2011-10-28 08:56:56 UTC:
CREATE TABLE GunsAndAmmo ( GunID INTEGER PRIMARY KEY AUTOINCREMENT, GunManufactor TEXT, GunModel TEXT, Division TEXT, Factor TEXT );

CREATE TABLE Shooters ( ShooterInternalID INTEGER PRIMARY KEY AUTOINCREMENT, DataBirth INTEGER, LastName TEXT, FirstName TEXT );

CREATE TABLE ShooterGun ( ShooterID INTEGER NOT NULL, GunID INTEGER NOT NULL, PRIMARY KEY (ShooterID, GunID ));

INSERT INTO GunsAndAmmo (GunID, GunManufactor, GunModel, Division, Factor) VALUES(2, 'CZ', 'SP-01', 'Shaddow', 'Open');
INSERT INTO GunsAndAmmo (GunID, GunManufactor, GunModel, Division, Factor) VALUES(3, 'CZ', 75, NULL, 'Production');

INSERT INTO Shooters (ShooterInternalID, DataBirth, LastName, FirstName) VALUES(1, 19800506, 'Aanonsen', 'Eirik');
INSERT INTO Shooters (ShooterInternalID, DataBirth, LastName, FirstName) VALUES(2, NULL, 'Westol', 'Stein');
INSERT INTO Shooters (ShooterInternalID, DataBirth, LastName, FirstName) VALUES(3, NULL, 'Eiriksa', 'Aasuhds');

INSERT INTO ShooterGun (ShooterID, GunID) VALUES(1, 3);
INSERT INTO ShooterGun (ShooterID, GunID) VALUES(1, 2);
INSERT INTO ShooterGun (ShooterID, GunID) VALUES(2, 2);
INSERT INTO ShooterGun (ShooterID, GunID) VALUES(2, 3);

SELECT Shooters.FirstName, Shooters.LastName, ShooterGun.ShooterID, GunsAndAmmo.Division, GunsAndAmmo.Factor, GunsAndAmmo.GunManufactor, GunsAndAmmo.GunModel
FROM Shooters, ShooterGun, GunsAndAmmo;

With this the problem exist. Gets only 2 results back. Also under 1.0.76.0 version. The differance is the ShooterGun table where I defined the two collums as primary keys.

Thank you for looking on this problem and please point out if I am wrong about something.


anonymous added on 2011-10-28 09:34:47 UTC:
IF I create the ShooterGun table with
UNIQUE (ShooterID, GunID )
insted of
PRIMARY KEY (ShooterID, GunID )
, it works as expected. Is this some design feture? I'm a bit puzzeled. Thanx for all and any feedback


mistachkin added on 2011-10-28 14:33:49 UTC:
I've been able to reproduce the results you are seeing. It appears that the built-in System.Data.DataTable class in the .NET Framework gets confused by the schema of your database. I'm still investigating this issue; however, I'm not sure how much can be done since the results returned by the System.Data.SQLite components are indeed correct (i.e. they return 24 rows).


mistachkin added on 2011-11-12 06:47:27 UTC:
May be related to this code fragment.


mistachkin added on 2011-11-13 06:00:47 UTC:
Fixed by check-in [da3e0bfb53]. The root cause of this issue was treating a column as 'unique' in multi-table data reader results just because it was unique in the underlying database table. For types of joins that can include multiple rows with the same value in that particular column (e.g. a cross join), this can cause serious problems.


mistachkin added on 2011-11-13 06:25:30 UTC:
Now checked into trunk [8fe2a401d6]. If possible, please test this fix in your environment and report back. If you need a custom binary compiled to facilitate this testing, just ask.