AlterTable invalid SQL
----------------------

                 Key: DNET-661
                 URL: http://tracker.firebirdsql.org/browse/DNET-661
             Project: .NET Data provider
          Issue Type: Bug
          Components: ADO.NET Provider
    Affects Versions: 4.9.0.0
            Reporter: Ludovic C.
            Assignee: Jiri Cincura


In EF6 migrations, when changing a SMALLINT field to a Bool field, the code 
generated is : 

AlterColumn("Firebird.I_T", "BOOLCOL", c => c.Boolean()) ->

ALTER TABLE "MYTABLE" ALTER COLUMN "BOOLCOL" TYPE SMALLINT CHECK("BOOLCOL" IN 
(0,1))

This is a invalid format, instead a "Bool" domain should be created

CEATE DOMAIN D_BOOL AS SMALLINT CHECK (VALUE in (0,1));

Then 

ALTER TABLE "MYTABLE" ALTER COLUMN "BOOLCOL" TYPE D_BOOL

Also, when doing migrations, if a nullable / non nullable is included, we get : 

AlterColumn("Firebird.I_T", "SYS", c => c.Boolean(nullable: false));

ALTER TABLE "I_T" ALTER COLUMN "SYS" TYPE SMALLINT NOT NULL CHECK("SYS" IN 
(0,1))

Which is not valid neither. Firebird does not support changing null to non null.

Instead it should be

UPDATE RDB$RELATION_FIELDS SET RDB$NULL_FLAG = NULL
WHERE RDB$FIELD_NAME = 'SYS' AND RDB$RELATION_NAME = 'I_T';
ALTER TABLE "I_T" ALTER COLUMN "SYS" TYPE D_BOOL;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to