Exemplo n.º 1
0
        private MySqlTypeBase GetMySqlTypeInt(DbTypeInt type)
        {
            if (type.GetSpecificAttribute("mysql", "subtype") == "bit")
            {
                MySqlTypeBit bit = new MySqlTypeBit();
                bit.Length = Int32.Parse(type.GetSpecificAttribute("mysql", "bitlength"));
                return(bit);
            }

            MySqlTypeInteger res;

            switch (type.Bytes)
            {
            case 1:
                res = new MySqlTypeTinyInt();
                break;

            case 2:
                res = new MySqlTypeSmallInt();
                break;

            case 3:
                res = new MySqlTypeMediumInt();
                break;

            case 4:
                res = new MySqlTypeInt();
                break;

            case 8:
                res = new MySqlTypeBigInt();
                break;

            default:
                res = new MySqlTypeInt();
                break;
            }
            res.IsAutoIncrement = type.Autoincrement;
            res.Unsigned        = type.Unsigned;
            res.Zerofill        = type.GetSpecificAttribute("mysql", "zerofill") == "1";
            string len = type.GetSpecificAttribute("mysql", "length");

            if (len != null)
            {
                res.Length = Int32.Parse(len);
            }
            return(res);
        }
Exemplo n.º 2
0
        protected MySqlTypeBase ReadMySqlDataType()
        {
            if (SkipTokenIf("bit"))
            {
                var res = new MySqlTypeBit();
                if (IsSymbol("("))
                {
                    ReadExprInBracket();
                }
                return(res);
            }
            if (SkipTokenIf("tinyint"))
            {
                return(ReadNumberType(new MySqlTypeTinyInt()));
            }
            if (SkipTokenIf("smallint"))
            {
                return(ReadNumberType(new MySqlTypeSmallInt()));
            }
            if (SkipTokenIf("mediumint"))
            {
                return(ReadNumberType(new MySqlTypeMediumInt()));
            }
            if (SkipTokenIf("int"))
            {
                return(ReadNumberType(new MySqlTypeInt()));
            }
            if (SkipTokenIf("integer"))
            {
                return(ReadNumberType(new MySqlTypeInt()));
            }
            if (SkipTokenIf("bigint"))
            {
                return(ReadNumberType(new MySqlTypeBigInt()));
            }

            if (SkipTokenIf("real"))
            {
                return(ReadNumberType(new MySqlTypeDouble()));
            }
            if (SkipMultiIf("double", "precision"))
            {
                return(ReadNumberType(new MySqlTypeDouble()));
            }
            if (SkipTokenIf("double"))
            {
                return(ReadNumberType(new MySqlTypeDouble()));
            }
            if (SkipTokenIf("float"))
            {
                return(ReadNumberType(new MySqlTypeFloat()));
            }
            if (SkipTokenIf("decimal"))
            {
                return(ReadNumberType(new MySqlTypeDecimal()));
            }
            if (SkipTokenIf("numeric"))
            {
                return(ReadNumberType(new MySqlTypeNumeric()));
            }

            if (SkipTokenIf("date"))
            {
                return(new MySqlTypeDate());
            }
            if (SkipTokenIf("time"))
            {
                return(new MySqlTypeTime());
            }
            if (SkipTokenIf("timestamp"))
            {
                return(new MySqlTypeTimestamp());
            }
            if (SkipTokenIf("datetime"))
            {
                return(new MySqlTypeDatetime());
            }
            if (SkipTokenIf("year"))
            {
                return(new MySqlTypeYear());
            }

            if (SkipTokenIf("char"))
            {
                return(ReadCharType(new MySqlTypeChar()));
            }
            if (SkipTokenIf("varchar"))
            {
                return(ReadCharType(new MySqlTypeVarChar()));
            }
            if (SkipTokenIf("binary"))
            {
                return(ReadCharType(new MySqlTypeBinary()));
            }
            if (SkipTokenIf("varbinary"))
            {
                return(ReadCharType(new MySqlTypeVarBinary()));
            }

            if (SkipTokenIf("tinyblob"))
            {
                return(new MySqlTypeTinyBlob());
            }
            if (SkipTokenIf("blob"))
            {
                return(new MySqlTypeBlob());
            }
            if (SkipTokenIf("mediumblob"))
            {
                return(new MySqlTypeMediumBlob());
            }
            if (SkipTokenIf("longblob"))
            {
                return(new MySqlTypeLongBlob());
            }

            if (SkipTokenIf("tinytext"))
            {
                return(ReadTextType(new MySqlTypeTinyText()));
            }
            if (SkipTokenIf("text"))
            {
                return(ReadTextType(new MySqlTypeText()));
            }
            if (SkipTokenIf("mediumtext"))
            {
                return(ReadTextType(new MySqlTypeMediumText()));
            }
            if (SkipTokenIf("longtext"))
            {
                return(ReadTextType(new MySqlTypeLongText()));
            }

            if (SkipTokenIf("enum"))
            {
                return(ReadNumSet(new MySqlTypeEnum()));
            }
            if (SkipTokenIf("set"))
            {
                return(ReadNumSet(new MySqlTypeSet()));
            }
            return(null);
        }