google-code-export / dblinq2007

Automatically exported from code.google.com/p/dblinq2007
Other
0 stars 0 forks source link

Two references to the same table cause DbMetal to crash (DbLinq-0.20.1) #278

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Tested on linux x86 with SQLite 3.6.22 , DbLinq-0.20.1 , mono 2.6.7

CREATE TABLE pet (
    idpet INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL,
    idmating INTEGER REFERENCES mating(idmating)
);
CREATE TABLE mating (
    idmating INTEGER PRIMARY KEY AUTOINCREMENT,
    idfather INTEGER REFERENCES pet(idpet),
    idmother INTEGER NOT NULL REFERENCES pet(idpet),
    matingday NUMERIC
);

./DbMetal.exe --provider=Sqlite --conn="Data Source=test.db" --code=testdb.cs 
--with-dbconnection="Mono.Data.Sqlite.SqliteConnection, Mono.Data.Sqlite, 
Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" --debug
DbLinq Database mapping generator 2008 version 0.20
for Microsoft (R) .NET Framework version 3.5
Distributed under the MIT licence (http://linq.to/db/license)

>>> Reading schema from SQLite database
DbMetal: System.InvalidOperationException: Operation is not valid due to the 
current state of the object
  at System.Linq.Enumerable.Single[Association] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00000] in <filename unknown>:0 
  at System.Linq.Enumerable.Single[Association] (IEnumerable`1 source, System.Func`2 predicate) [0x00000] in <filename unknown>:0 
  at DbMetal.Generator.Implementation.Processor.ValidateAssociations (DbLinq.Schema.Dbml.Database database, DbLinq.Schema.Dbml.Table table) [0x00000] in <filename unknown>:0 
  at DbMetal.Generator.Implementation.Processor.SchemaIsValid (DbLinq.Schema.Dbml.Database database) [0x00000] in <filename unknown>:0 
  at DbMetal.Generator.Implementation.Processor.ProcessSchema (DbMetal.Parameters parameters) [0x00000] in <filename unknown>:0 

I have the same error in MonoDevelop whith "Generate linq class"

Removing one of the two REFERENCES pet(idpet) solve it

Original issue reported on code.google.com by gauthier...@yahoo.fr on 23 Aug 2010 at 7:57