private void TypeEdited(object sender, EditedArgs args)
        {
            TreeIter iter;

            if (storeColumns.GetIterFromString(out iter, args.Path))
            {
                if (!string.IsNullOrEmpty(args.NewText))
                {
                    ColumnSchema column = storeColumns.GetValue(iter, colObjIndex) as ColumnSchema;

                    int len = int.Parse(storeColumns.GetValue(iter, colLengthIndex) as string);
                    if (column.DataType.LengthRange.Default == len)
                    {
                        //change the length if it is still the default length
                        DataTypeSchema dtNew = schemaProvider.GetDataType(args.NewText);
                        storeColumns.SetValue(iter, colLengthIndex, dtNew.LengthRange.Default.ToString());
                    }

                    storeColumns.SetValue(iter, colTypeIndex, args.NewText);
                    column.DataTypeName = args.NewText;
                    EmitContentChanged();
                }
                else
                {
                    string oldText = storeColumns.GetValue(iter, colTypeIndex) as string;
                    (sender as CellRendererText).Text = oldText;
                }
            }
        }
        private void PropTypeDataFunc(CellLayout layout, CellRenderer cell, TreeModel model, TreeIter iter)
        {
            CellRendererText textRenderer = cell as CellRendererText;
            ColumnContainer  container    = model.GetValue(iter, columnObj) as ColumnContainer;
            DataTypeSchema   dt           = container.ColumnSchema.DataType;

            ISchemaProvider provider = dt.SchemaProvider;
            Type            type     = dt.DotNetType;

            textRenderer.Text = type.Name;
        }
        public virtual bool ValidateSchemaObjects(out string msg)
        {
            TreeIter iter;

            if (storeColumns.GetIterFirst(out iter))
            {
                bool isPk = constraints.GetConstraint(ConstraintType.PrimaryKey) != null;
                do
                {
                    string name = storeColumns.GetValue(iter, colNameIndex) as string;
                    string type = storeColumns.GetValue(iter, colTypeIndex) as string;
                    int    len  = int.Parse(storeColumns.GetValue(iter, colLengthIndex) as string);
                    if (!isPk)
                    {
                        isPk = (bool)storeColumns.GetValue(iter, colPKIndex);
                    }

                    DataTypeSchema dt = schemaProvider.GetDataType(type);
                    if (dt == null)
                    {
                        msg = AddinCatalog.GetString("Unknown data type '{0}' applied to column '{1}'.", type, name);
                        return(false);
                    }

                    //TODO: enable when all providers have good datatype info
//					if (!dt.LengthRange.IsInRange (len)) {
//						msg = AddinCatalog.GetString ("Invalid length for '{0}'.", name);
//						return false;
//					}
                } while (storeColumns.IterNext(ref iter));

                if (!isPk)
                {
                    msg = AddinCatalog.GetString("Table '{0}' must contain at least one primary key.", table.Name);
                    return(false);
                }
                else
                {
                    msg = null;
                    return(true);
                }
            }
            msg = AddinCatalog.GetString("Table '{0}' must contain at least 1 column.", table.Name);
            return(false);
        }
            void IXmlSerializable.ReadXml(XmlReader reader)
            {
                bool?  serializePropertyAsAttribute = reader.GetAttributeAsBool("SerializePropertyAsAttribute");
                bool?  emitNullValue = reader.GetAttributeAsBool("EmitNullValue");
                string typeSchema    = reader.GetAttribute("TypeSchema");

                if (serializePropertyAsAttribute.HasValue)
                {
                    _SerializePropertyAsAttribute = serializePropertyAsAttribute.Value;
                }

                if (emitNullValue.HasValue)
                {
                    _EmitNullValue = emitNullValue.Value;
                }

                if (!string.IsNullOrWhiteSpace(typeSchema))
                {
                    _TypeSchema = (DataTypeSchema)Enum.Parse(typeof(DataTypeSchema), typeSchema, true);
                }
            }
            internal void ReadXml(XElement xe)
            {
                XNamespace defaultNamespace             = xe.GetDefaultNamespace();
                bool?      serializePropertyAsAttribute = (bool?)xe.Attribute(defaultNamespace + "SerializePropertyAsAttribute");
                bool?      emitNullValue = (bool?)xe.Attribute(defaultNamespace + "EmitNullValue");
                string     typeSchema    = (string)xe.Attribute(defaultNamespace + "TypeSchema");

                if (serializePropertyAsAttribute.HasValue)
                {
                    _SerializePropertyAsAttribute = serializePropertyAsAttribute.Value;
                }

                if (emitNullValue.HasValue)
                {
                    _EmitNullValue = emitNullValue.Value;
                }

                if (!string.IsNullOrWhiteSpace(typeSchema))
                {
                    _TypeSchema = (DataTypeSchema)Enum.Parse(typeof(DataTypeSchema), typeSchema, true);
                }
            }
        // see:
        // http://www.firebirdsql.org/manual/migration-mssql-data-types.html
        // http://webcoder.info/reference/MSSQLDataTypes.html
        // http://www.tar.hu/sqlbible/sqlbible0022.html
        // http://msdn2.microsoft.com/en-us/library/aa258876(SQL.80).aspx
        public override DataTypeSchema GetDataType(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            name = name.ToLower();

            DataTypeSchema dts = new DataTypeSchema(this);

            dts.Name = name;
            switch (name)
            {
            case "bigint":
                dts.LengthRange      = new Range(8);
                dts.PrecisionRange   = new Range(1, 19);
                dts.DataTypeCategory = DataTypeCategory.Integer;
                break;

            case "binary":
                dts.LengthRange      = new Range(1, 8004);
                dts.PrecisionRange   = new Range(1, 8000);
                dts.DataTypeCategory = DataTypeCategory.Binary;
                break;

            case "bit":
                dts.LengthRange      = new Range(1);
                dts.DataTypeCategory = DataTypeCategory.Bit;
                break;

            case "char":
                dts.LengthRange      = new Range(1, 8000);
                dts.PrecisionRange   = new Range(1, 8000);
                dts.DataTypeCategory = DataTypeCategory.Char;
                break;

            case "datetime":
                dts.LengthRange      = new Range(8);
                dts.DataTypeCategory = DataTypeCategory.DateTime;
                break;

            case "decimal":
                dts.LengthRange      = new Range(5, 17);
                dts.PrecisionRange   = new Range(1, 38);
                dts.ScaleRange       = new Range(0, 37);
                dts.DataTypeCategory = DataTypeCategory.Float;
                break;

            case "float":
                dts.LengthRange      = new Range(8);
                dts.ScaleRange       = new Range(1, 15);
                dts.DataTypeCategory = DataTypeCategory.Float;
                break;

            case "image":
                dts.LengthRange      = new Range(0, int.MaxValue);
                dts.PrecisionRange   = new Range(0, int.MaxValue);
                dts.DataTypeCategory = DataTypeCategory.VarBinary;
                break;

            case "int":
                dts.LengthRange      = new Range(4);
                dts.PrecisionRange   = new Range(1, 10);
                dts.DataTypeCategory = DataTypeCategory.Integer;
                break;

            case "money":
                dts.LengthRange      = new Range(8);
                dts.PrecisionRange   = new Range(1, 19);
                dts.ScaleRange       = new Range(4);
                dts.DataTypeCategory = DataTypeCategory.Integer;
                break;

            case "nchar":
                dts.LengthRange      = new Range(2, 8000);
                dts.PrecisionRange   = new Range(1, 4000);
                dts.DataTypeCategory = DataTypeCategory.NChar;
                break;

            case "ntext":
                dts.LengthRange      = new Range(0, int.MaxValue);
                dts.PrecisionRange   = new Range(0, 1073741823);
                dts.DataTypeCategory = DataTypeCategory.NVarChar;
                break;

            case "numeric":
                dts.LengthRange      = new Range(5, 17);
                dts.PrecisionRange   = new Range(1, 38);
                dts.ScaleRange       = new Range(0, 37);
                dts.DataTypeCategory = DataTypeCategory.Float;
                break;

            case "nvarchar":
                dts.LengthRange      = new Range(0, 8000);
                dts.PrecisionRange   = new Range(0, 4000);
                dts.DataTypeCategory = DataTypeCategory.NVarChar;
                break;

            case "real":
                dts.LengthRange      = new Range(4);
                dts.ScaleRange       = new Range(7);
                dts.DataTypeCategory = DataTypeCategory.Float;
                break;

            case "smalldatetime":
                dts.LengthRange      = new Range(4);
                dts.DataTypeCategory = DataTypeCategory.DateTime;
                break;

            case "smallint":
                dts.LengthRange      = new Range(2);
                dts.PrecisionRange   = new Range(5);
                dts.DataTypeCategory = DataTypeCategory.Integer;
                break;

            case "smallmoney":
                dts.LengthRange      = new Range(4);
                dts.PrecisionRange   = new Range(10);
                dts.ScaleRange       = new Range(4);
                dts.DataTypeCategory = DataTypeCategory.Integer;
                break;

            case "text":
                dts.LengthRange      = new Range(0, int.MaxValue);
                dts.PrecisionRange   = new Range(0, int.MaxValue);
                dts.DataTypeCategory = DataTypeCategory.VarChar;
                break;

            case "timestamp":
                dts.LengthRange      = new Range(1, 8);
                dts.DataTypeCategory = DataTypeCategory.TimeStamp;
                break;

            case "tinyint":
                dts.LengthRange      = new Range(1);
                dts.PrecisionRange   = new Range(1, 3);
                dts.DataTypeCategory = DataTypeCategory.Integer;
                break;

            case "varbinary":
                dts.LengthRange      = new Range(1, 8004);
                dts.PrecisionRange   = new Range(0, 8000);
                dts.DataTypeCategory = DataTypeCategory.VarBinary;
                break;

            case "varchar":
                dts.LengthRange      = new Range(1, 8000);
                dts.PrecisionRange   = new Range(0, 8000);
                dts.DataTypeCategory = DataTypeCategory.VarChar;
                break;

            case "uniqueidentifier":
                dts.LengthRange      = new Range(16);
                dts.DataTypeCategory = DataTypeCategory.Uid;
                break;

            case "xml":
                dts.LengthRange      = new Range(0, int.MaxValue);
                dts.PrecisionRange   = new Range(0, int.MaxValue);
                dts.DataTypeCategory = DataTypeCategory.VarChar;
                break;

            case "cursor":
            case "table":
            case "sql_variant":
                dts.DataTypeCategory = DataTypeCategory.Other;
                break;

            default:
                break;
            }

            return(dts);
        }
		// see:
		// http://www.htmlite.com/mysql003.php
		// http://kimbriggs.com/computers/computer-notes/mysql-notes/mysql-data-types.file
		// http://dev.mysql.com/doc/refman/5.1/en/data-type-overview.html
		public override DataTypeSchema GetDataType (string name)
		{
			if (name == null)
				throw new ArgumentNullException ("name");

			string type = null;
			int length = 0;
			int scale = 0;
			ParseType (name, out type, out length, out scale);

			DataTypeSchema dts = new DataTypeSchema (this);
			dts.Name = type;
			switch (type.ToLower ()) {
				case "tinyint":
				case "smallint":
				case "mediumint":
				case "int":
				case "integer":
				case "bigint":
					dts.LengthRange = new Range (length);
					dts.DataTypeCategory = DataTypeCategory.Integer;
					break;
				case "bit":
					dts.LengthRange = new Range (length); //in bits
					dts.DataTypeCategory = DataTypeCategory.Bit;
					break;
				case "bool":
				case "boolean":
					dts.LengthRange = new Range (1); //in bits
					dts.DataTypeCategory = DataTypeCategory.Boolean;
					break;
				case "float":
				case "double":
				case "double precision":
				case "decimal":
				case "dec":
					dts.LengthRange = new Range (length);
					dts.ScaleRange = new Range (scale);
					dts.DataTypeCategory = DataTypeCategory.Boolean;
					break;
				case "date":
					dts.DataTypeCategory = DataTypeCategory.Date;
					break;
				case "datetime":
					dts.DataTypeCategory = DataTypeCategory.DateTime;
					break;
				case "timestamp":
					dts.DataTypeCategory = DataTypeCategory.TimeStamp;
					break;
				case "time":
					dts.DataTypeCategory = DataTypeCategory.Time;
					break;
				case "year":
					dts.LengthRange = new Range (length);
					dts.DataTypeCategory = DataTypeCategory.Integer;
					break;
				case "binary":
				case "char byte":
					dts.LengthRange = new Range (length);
					dts.DataTypeCategory = DataTypeCategory.Binary;
					break;
				case "varbinary":
					dts.LengthRange = new Range (length);
					dts.DataTypeCategory = DataTypeCategory.VarBinary;
					break;
				case "tinyblob":
				case "mediumblob":
				case "longblob":
				case "blob":
					dts.LengthRange = new Range (length);
					dts.DataTypeCategory = DataTypeCategory.Binary;
					break;
				case "tinytext":
				case "mediumtext":
				case "longtext":
				case "text":
					dts.LengthRange = new Range (length);
					dts.DataTypeCategory = DataTypeCategory.NChar;
					break;
				case "national char":
				case "nchar":
					dts.LengthRange = new Range (length);
					dts.DataTypeCategory = DataTypeCategory.NChar;
					break;
				case "national varchar":
				case "nvarchar":
					dts.LengthRange = new Range (length);
					dts.DataTypeCategory = DataTypeCategory.NVarChar;
					break;
				case "varchar":
					dts.LengthRange = new Range (length);
					dts.DataTypeCategory = DataTypeCategory.VarChar;
					break;
				case "char":
					dts.LengthRange = new Range (length);
					dts.DataTypeCategory = DataTypeCategory.Char;
					break;
				case "set":
				case "enum":
					dts.DataTypeCategory = DataTypeCategory.Integer;
					break;
				default:
					dts = null;
					break;
			}
			
			return dts;
		}
Exemplo n.º 8
0
        // see:
        // http://www.htmlite.com/mysql003.php
        // http://kimbriggs.com/computers/computer-notes/mysql-notes/mysql-data-types.file
        // http://dev.mysql.com/doc/refman/5.1/en/data-type-overview.html
        public override DataTypeSchema GetDataType(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            string type   = null;
            int    length = 0;
            int    scale  = 0;

            ParseType(name, out type, out length, out scale);

            DataTypeSchema dts = new DataTypeSchema(this);

            dts.Name = type;
            switch (type.ToLower())
            {
            case "tinyint":
            case "smallint":
            case "mediumint":
            case "int":
            case "integer":
            case "bigint":
                dts.LengthRange      = new Range(length);
                dts.DataTypeCategory = DataTypeCategory.Integer;
                break;

            case "bit":
                dts.LengthRange      = new Range(length);                     //in bits
                dts.DataTypeCategory = DataTypeCategory.Bit;
                break;

            case "bool":
            case "boolean":
                dts.LengthRange      = new Range(1);                     //in bits
                dts.DataTypeCategory = DataTypeCategory.Boolean;
                break;

            case "float":
            case "double":
            case "double precision":
            case "decimal":
            case "dec":
                dts.LengthRange      = new Range(length);
                dts.ScaleRange       = new Range(scale);
                dts.DataTypeCategory = DataTypeCategory.Boolean;
                break;

            case "date":
                dts.DataTypeCategory = DataTypeCategory.Date;
                break;

            case "datetime":
                dts.DataTypeCategory = DataTypeCategory.DateTime;
                break;

            case "timestamp":
                dts.DataTypeCategory = DataTypeCategory.TimeStamp;
                break;

            case "time":
                dts.DataTypeCategory = DataTypeCategory.Time;
                break;

            case "year":
                dts.LengthRange      = new Range(length);
                dts.DataTypeCategory = DataTypeCategory.Integer;
                break;

            case "binary":
            case "char byte":
                dts.LengthRange      = new Range(length);
                dts.DataTypeCategory = DataTypeCategory.Binary;
                break;

            case "varbinary":
                dts.LengthRange      = new Range(length);
                dts.DataTypeCategory = DataTypeCategory.VarBinary;
                break;

            case "tinyblob":
            case "mediumblob":
            case "longblob":
            case "blob":
                dts.LengthRange      = new Range(length);
                dts.DataTypeCategory = DataTypeCategory.Binary;
                break;

            case "tinytext":
            case "mediumtext":
            case "longtext":
            case "text":
                dts.LengthRange      = new Range(length);
                dts.DataTypeCategory = DataTypeCategory.NChar;
                break;

            case "national char":
            case "nchar":
                dts.LengthRange      = new Range(length);
                dts.DataTypeCategory = DataTypeCategory.NChar;
                break;

            case "national varchar":
            case "nvarchar":
                dts.LengthRange      = new Range(length);
                dts.DataTypeCategory = DataTypeCategory.NVarChar;
                break;

            case "varchar":
                dts.LengthRange      = new Range(length);
                dts.DataTypeCategory = DataTypeCategory.VarChar;
                break;

            case "char":
                dts.LengthRange      = new Range(length);
                dts.DataTypeCategory = DataTypeCategory.Char;
                break;

            case "set":
            case "enum":
                dts.DataTypeCategory = DataTypeCategory.Integer;
                break;

            default:
                dts = null;
                break;
            }

            return(dts);
        }
Exemplo n.º 9
0
		
		public override DataTypeSchemaCollection GetDataTypes ()
		{
			DataTypeSchemaCollection collection = new DataTypeSchemaCollection ();
			
			#region Types
			// ENUM
			DataTypeSchema schema = new DataTypeSchema (this);
			schema.Name = "smallint";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(Int16);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = true;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			// Integer
			schema = new DataTypeSchema (this);
			schema.Name = "integer";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(int);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = true;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			// Big Int
			schema = new DataTypeSchema (this);
			schema.Name = "bigint";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(long);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = true;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			// Serial
			schema = new DataTypeSchema (this);
			schema.Name = "serial";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(long);
			schema.IsAutoincrementable = true;
			schema.IsFixedLength = true;
			schema.IsNullable = false;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			// Big Serial
			schema = new DataTypeSchema (this);
			schema.Name = "bigserial";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(long);
			schema.IsAutoincrementable = true;
			schema.IsFixedLength = true;
			schema.IsNullable = false;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			// Numeric
			schema = new DataTypeSchema (this);
			schema.Name = "numeric";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(float);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = false;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			// Decimal
			schema = new DataTypeSchema (this);
			schema.Name = "decimal";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(float);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = false;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			// real
			schema = new DataTypeSchema (this);
			schema.Name = "real";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(float);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = false;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			// double precision
			schema = new DataTypeSchema (this);
			schema.Name = "double precision";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(float);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = false;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);

			// money
			schema = new DataTypeSchema (this);
			schema.Name = "money";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(float);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = false;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);

			// character varying
			schema = new DataTypeSchema (this);
			schema.Name = "character varying";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(string);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = false;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);

			// varying
			schema = new DataTypeSchema (this);
			schema.Name = "varying";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(string);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = false;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);

			// varchar
			schema = new DataTypeSchema (this);
			schema.Name = "varchar";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(string);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = false;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);

			// text
			schema = new DataTypeSchema (this);
			schema.Name = "text";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(string);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = false;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);

			// character
			schema = new DataTypeSchema (this);
			schema.Name = "character";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(string);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = false;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			// char
			schema = new DataTypeSchema (this);
			schema.Name = "char";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(string);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = false;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			// bytea
			schema = new DataTypeSchema (this);
			schema.Name = "bytea";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(byte);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = false;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);			

			// timeSpan
			schema = new DataTypeSchema (this);
			schema.Name = "timespan";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(object);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = true;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);

			// interval
			schema = new DataTypeSchema (this);
			schema.Name = "interval";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(TimeSpan);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = true;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			// Date
			schema = new DataTypeSchema (this);
			schema.Name = "date";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(DateTime);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = true;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			// Time
			schema = new DataTypeSchema (this);
			schema.Name = "time";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(DateTime);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = true;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			// boolean
			schema = new DataTypeSchema (this);
			schema.Name = "boolean";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(bool);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = true;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			// bit
			schema = new DataTypeSchema (this);
			schema.Name = "bit";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(bool);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = true;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			// uuid
			schema = new DataTypeSchema (this);
			schema.Name = "bit";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(Guid);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = true;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			// xml
			schema = new DataTypeSchema (this);
			schema.Name = "xml";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(Guid);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = true;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			// point
			schema = new DataTypeSchema (this);
			schema.Name = "point";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(string);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = true;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			// line
			schema = new DataTypeSchema (this);
			schema.Name = "line";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(string);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = true;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			// lseg
			schema = new DataTypeSchema (this);
			schema.Name = "lseg";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(string);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = true;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			// box
			schema = new DataTypeSchema (this);
			schema.Name = "box";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(string);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = true;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			// polygon
			schema = new DataTypeSchema (this);
			schema.Name = "polygon";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(string);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = true;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			// circle
			schema = new DataTypeSchema (this);
			schema.Name = "circle";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(string);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = true;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			// inet
			schema = new DataTypeSchema (this);
			schema.Name = "inet";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(string);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = true;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			
			// cidr
			schema = new DataTypeSchema (this);
			schema.Name = "cidr";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(string);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = true;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			schema = new DataTypeSchema (this);
			schema.Name = "enum";
			schema.LengthRange = new Range (0);
			schema.DotNetType = typeof(object);
			schema.IsAutoincrementable = false;
			schema.IsFixedLength = false;
			schema.IsNullable = true;
			schema.ScaleRange = new Range (0, 0);
			schema.PrecisionRange = new Range (0, 0);
			collection.Add (schema);
			
			#endregion 
			return collection;
Exemplo n.º 10
0
		public override DataTypeSchema GetDataType (string name)
		{
			if (name == null)
				throw new ArgumentNullException ("name");
			
			if (name == null)
				throw new ArgumentNullException ("name");

			string type = null;
			int length = 0;
			int scale = 0;
			ParseType (name, out type, out length, out scale);

			DataTypeSchema dts = new DataTypeSchema (this);
			dts.Name = type;
			switch (type) {
				case "enum":
				case "smallint":
				case "integer":
				case "bigint":
				case "serial":
				case "bigserial":
					dts.LengthRange = new Range (length);
					dts.DataTypeCategory = DataTypeCategory.Integer;
					break;
				case "numeric":
				case "decimal":
				case "real":
				case "double precision":
				case "money":
					dts.LengthRange = new Range (length);
					dts.ScaleRange = new Range (scale);
					dts.DataTypeCategory = DataTypeCategory.Float;
					break;
				case "character varying":
				case "varying":
				case "varchar":
				case "text":
					dts.LengthRange = new Range (length);
					dts.DataTypeCategory = DataTypeCategory.VarChar;
					break;
				case "character":
				case "char":
					dts.LengthRange = new Range (length);
					dts.DataTypeCategory = DataTypeCategory.Char;
					break;
				case "bytea":
					dts.LengthRange = new Range (length);
					dts.DataTypeCategory = DataTypeCategory.Binary;
					break;
				case "timestamp":
					dts.DataTypeCategory = DataTypeCategory.TimeStamp;
					break;
				case "interval":
					dts.DataTypeCategory = DataTypeCategory.Interval;
					break;
				case "date":
					dts.DataTypeCategory = DataTypeCategory.Date;
					break;
				case "time":
					dts.DataTypeCategory = DataTypeCategory.Time;
					break;
				case "boolean":
					dts.DataTypeCategory = DataTypeCategory.Bit;
					break;
				case "point":
				case "line":
				case "lseg":
				case "box":
				case "polygon":
				case "circle":
				case "inet":
				case "cidr":
					// Research this
					dts.DataTypeCategory = DataTypeCategory.VarChar;
					break;
				case "bit":
					dts.DataTypeCategory = DataTypeCategory.Bit;
					break;
				case "uuid":
					dts.DataTypeCategory = DataTypeCategory.Uid;
					break;
				case "xml":
					dts.DataTypeCategory = DataTypeCategory.Xml;
					break;
				default:
					dts.DataTypeCategory = DataTypeCategory.Other;
					break;
			}
			
			return dts;
Exemplo n.º 11
0
		
		// see:
		// http://www.firebirdsql.org/manual/migration-mssql-data-types.html
		// http://webcoder.info/reference/MSSQLDataTypes.html
		// http://www.tar.hu/sqlbible/sqlbible0022.html
		// http://msdn2.microsoft.com/en-us/library/aa258876(SQL.80).aspx
		public override DataTypeSchema GetDataType (string name)
		{
			if (name == null)
				throw new ArgumentNullException ("name");
			name = name.ToLower ();

			DataTypeSchema dts = new DataTypeSchema (this);
			dts.Name = name;
			switch (name) {
				case "bigint":
					dts.LengthRange = new Range (8);
					dts.PrecisionRange = new Range (1, 19);
					dts.DataTypeCategory = DataTypeCategory.Integer;
					break;
				case "binary":
					dts.LengthRange = new Range (1, 8004);
					dts.PrecisionRange = new Range (1, 8000);
					dts.DataTypeCategory = DataTypeCategory.Binary;
					break;
				case "bit":
					dts.LengthRange = new Range (1);
					dts.DataTypeCategory = DataTypeCategory.Bit;
					break;
				case "char":
					dts.LengthRange = new Range (1, 8000);
					dts.PrecisionRange = new Range (1, 8000);
					dts.DataTypeCategory = DataTypeCategory.Char;
					break;
				case "datetime":
					dts.LengthRange = new Range (8);
					dts.DataTypeCategory = DataTypeCategory.DateTime;
					break;
				case "decimal":
					dts.LengthRange = new Range (5, 17);
					dts.PrecisionRange = new Range (1, 38);
					dts.ScaleRange = new Range (0, 37);
					dts.DataTypeCategory = DataTypeCategory.Float;
					break;
				case "float":
					dts.LengthRange = new Range (8);
					dts.ScaleRange = new Range (1, 15);
					dts.DataTypeCategory = DataTypeCategory.Float;
					break;
				case "image":
					dts.LengthRange = new Range (0, int.MaxValue);
					dts.PrecisionRange = new Range (0, int.MaxValue);
					dts.DataTypeCategory = DataTypeCategory.VarBinary;
					break;
				case "int":
					dts.LengthRange = new Range (4);
					dts.PrecisionRange = new Range (1, 10);
					dts.DataTypeCategory = DataTypeCategory.Integer;
					break;
				case "money":
					dts.LengthRange = new Range (8);
					dts.PrecisionRange = new Range (1, 19);
					dts.ScaleRange = new Range (4);
					dts.DataTypeCategory = DataTypeCategory.Integer;
					break;
				case "nchar":
					dts.LengthRange = new Range (2, 8000);
					dts.PrecisionRange = new Range (1, 4000);
					dts.DataTypeCategory = DataTypeCategory.NChar;
					break;
				case "ntext":
					dts.LengthRange = new Range (0, int.MaxValue);
					dts.PrecisionRange = new Range (0, 1073741823);
					dts.DataTypeCategory = DataTypeCategory.NVarChar;
					break;
				case "numeric":
					dts.LengthRange = new Range (5, 17);
					dts.PrecisionRange = new Range (1, 38);
					dts.ScaleRange = new Range (0, 37);
					dts.DataTypeCategory = DataTypeCategory.Float;
					break;
				case "nvarchar":
					dts.LengthRange = new Range (0, 8000);
					dts.PrecisionRange = new Range (0, 4000);
					dts.DataTypeCategory = DataTypeCategory.NVarChar;
					break;
				case "real":
					dts.LengthRange = new Range (4);
					dts.ScaleRange = new Range (7);
					dts.DataTypeCategory = DataTypeCategory.Float;
					break;
				case "smalldatetime":
					dts.LengthRange = new Range (4);
					dts.DataTypeCategory = DataTypeCategory.DateTime;
					break;
				case "smallint":
					dts.LengthRange = new Range (2);
					dts.PrecisionRange = new Range (5);
					dts.DataTypeCategory = DataTypeCategory.Integer;
					break;
				case "smallmoney":
					dts.LengthRange = new Range (4);
					dts.PrecisionRange = new Range (10);
					dts.ScaleRange = new Range (4);
					dts.DataTypeCategory = DataTypeCategory.Integer;
					break;
				case "text":
					dts.LengthRange = new Range (0, int.MaxValue);
					dts.PrecisionRange = new Range (0, int.MaxValue);
					dts.DataTypeCategory = DataTypeCategory.VarChar;
					break;
				case "timestamp":
					dts.LengthRange = new Range (1, 8);
					dts.DataTypeCategory = DataTypeCategory.TimeStamp;
					break;
				case "tinyint":
					dts.LengthRange = new Range (1);
					dts.PrecisionRange = new Range (1, 3);
					dts.DataTypeCategory = DataTypeCategory.Integer;
					break;
				case "varbinary":
					dts.LengthRange = new Range (1, 8004);
					dts.PrecisionRange = new Range (0, 8000);
					dts.DataTypeCategory = DataTypeCategory.VarBinary;
					break;
				case "varchar":
					dts.LengthRange = new Range (1, 8000);
					dts.PrecisionRange = new Range (0, 8000);
					dts.DataTypeCategory = DataTypeCategory.VarChar;
					break;
				case "uniqueidentifier":
					dts.LengthRange = new Range (16);
					dts.DataTypeCategory = DataTypeCategory.Uid;
					break;
				case "xml":
					dts.LengthRange = new Range (0, int.MaxValue);
					dts.PrecisionRange = new Range (0, int.MaxValue);
					dts.DataTypeCategory = DataTypeCategory.VarChar;
					break;
				case "cursor":
				case "table":
				case "sql_variant":
					dts.DataTypeCategory = DataTypeCategory.Other;
					break;
				default:
					break;
			}
			
			return dts;