Open
Description
Alexei Shcherbakov created an issue — 18th August 2014, 8:43:57:
When Entity is mapped by code SQL table creation code for SQLite is invalid
For example for entity:public class Tag { public virtual long ID{get;set;} public virtual string Name{get;set;} public virtual int TagType{get;set;} public virtual int Color{get;set} public virtual Tag Parent{get;set;} public virtual ISet<Tag> Children{get;set;} }and mapping:
mapper.Class<Tag>( clazz => { clazz.Table( TABLE_TAG ); clazz.Id( x => x.ID, map => { map.Generator( Generators.Native ); map.Column( FIELD_ID ); } ); clazz.Property( x => x.Name, map => { map.Column( "name" ); map.NotNullable( true ); } ); clazz.Property( x => x.TagType, map => { map.Column( column => { column.Name( "type" ); column.Default( 0 ); } ); map.NotNullable( true ); } ); clazz.Property( x => x.Color, map => { map.Column( column => { column.Name( "color" ); column.Default( 0 ); } ); map.NotNullable( true ); } ); clazz.ManyToOne( x => x.Parent, many2one => { many2one.Fetch( FetchKind.Join ); many2one.Column( "parent_id" ); many2one.NotFound( NotFoundMode.Ignore ); } ); clazz.Set( x => x.Children, set => { set.Table( TABLE_TAG ); set.Key( key => { key.Column( "parent_id" ); } ); set.Inverse( true ); }, relation => relation.OneToMany() ); } );SchemaExport creates SQL with empty referenced field:
CREATE TABLE tag ( id integer PRIMARY KEY AUTOINCREMENT, name text NOT NULL, type int NOT NULL DEFAULT 0, color int NOT NULL DEFAULT 0, parent_id bigint, /** Foreign keys **/ FOREIGN KEY (parent_id) REFERENCES tag() ON DELETE NO ACTION ON UPDATE NO ACTION );But it must generate:
REFERENCES tag(id)