public override string SerializeAlterTableFieldsModifier(SQLTableFields.AlterModeType alterMode)
 {
     if (alterMode == SQLTableFields.AlterModeType.Drop)
         throw new NotSupportedException("SQLite does not support dropping a column");
     else
         return base.SerializeAlterTableFieldsModifier(alterMode);
 }
 public override string SerializeColumnAlterMode(SQLTableFields.AlterModeType alterMode)
 {
     switch (alterMode)
     {
         case SQLTableFields.AlterModeType.Modify:
             return "MODIFY COLUMN";
         default:
             return base.SerializeColumnAlterMode(alterMode);
     }
 }
示例#3
0
 public virtual string SerializeColumnAlterMode(SQLTableFields.AlterModeType alterMode)
 {
     switch (alterMode)
     {
         case SQLTableFields.AlterModeType.Add:
             return "ADD";
         case SQLTableFields.AlterModeType.Modify:
             return "ALTER COLUMN";
         case SQLTableFields.AlterModeType.Drop:
             return "DROP COLUMN";
         default:
             throw new NotImplementedException();
     }
 }
示例#4
0
 /// <summary>
 /// The field modifier that is used before all of the fields modifications are listed.
 /// Typically used by SQL Server to indicate the type of operation to be performed on ALL fields.
 /// </summary>
 /// <param name="tableFields"></param>
 /// <returns></returns>
 public virtual string SerializeAlterTableFieldsModifier(SQLTableFields.AlterModeType alterMode)
 {
     return SerializeColumnAlterMode(alterMode);
 }
示例#5
0
        /// <summary>
        /// </summary>
        /// <param name="includeColumnModifier">
        /// Indicates whether the ADD, MODIFY or DROP modifiers are required for each column.
        /// When utilised from SQLCreateTable this will always be false. However, for SQLAlterTable this will be true.</param>
        /// <returns></returns>
        public virtual string SerializeTableFields(SQLTableFields tableFields, bool includeColumnModifier)
        {
            var tokens = new TokenSerializer();

            //Include mode when altering a table, otherwise when creating a table the mode is not required.
            if (includeColumnModifier)
                tokens.Add(SerializeAlterTableFieldsModifier(tableFields.AlterMode));

            var fieldsTokens = new TokenSerializer(", ");

            foreach (SQLTableFieldBase field in tableFields)
            {
                var fieldToken = new TokenSerializer();

                if (includeColumnModifier)
                    fieldToken.Add(SerializeAlterTableFieldModifier(tableFields.AlterMode));

                fieldToken.Add(field.SQL(this, tableFields.AlterMode));

                fieldsTokens.Add(fieldToken.ToString());
            }

            tokens.Add(fieldsTokens.ToString());

            return tokens.ToString();
        }
示例#6
0
 /// <summary>
 /// The field modifier that is used before each field that is being modified.
 /// Typically used by MySQL the type of operation to be performed on each field.
 /// </summary>
 /// <param name="tableFields"></param>
 /// <returns></returns>
 public virtual string SerializeAlterTableFieldModifier(SQLTableFields.AlterModeType alterMode)
 {
     return String.Empty;
 }
示例#7
0
        public virtual string SerializeTableFieldComputed(SQLTableFieldComputed tableFieldComputed, SQLTableFields.AlterModeType alterMode)
        {
            if (alterMode == SQLTableFields.AlterModeType.Drop)
                throw new InvalidOperationException("Computed columns cannot be used for dropping fields");

            return tableFieldComputed.NameAsExpression.SQL(this) + " AS (" + tableFieldComputed.Computation.SQL(this) + ")";
        }
示例#8
0
        public virtual string SerializeTableField(SQLTableField field, SQLTableFields.AlterModeType alterMode)
        {
            var tokens = new TokenSerializer();

            if (alterMode == SQLTableFields.AlterModeType.Drop)
                tokens.Add(SerializeTableFieldAsName(field));
            else
            {
                tokens.Add(SerializeTableFieldAsName(field));
                tokens.Add(SerializeTableFieldDataType(field));
                tokens.Add(SerializeTableFieldCollationOption(field));
                tokens.Add(SerializeTableFieldDefaultOption(field));
                tokens.Add(SerializeTableFieldNullableOption(field));
                tokens.Add(SerializeTableFieldKeyTypeOption(field));
            }

            return tokens.ToString();
        }
 public SQLCreateTable()
 {
     pobjFields = new SQLTableFields();
     pobjFields.AlterMode = SQLTableFields.AlterModeType.Add; //set that fields can only be added
 }
 public override string SerializeAlterTableFieldsModifier(SQLTableFields.AlterModeType alterMode)
 {
     // For MySQL the modifiers are added for each column not for all of the columns.
     // So override the SerializeAlterTableFieldModifier instead.
     return String.Empty;
 }
 public override string SerializeAlterTableFieldModifier(SQLTableFields.AlterModeType alterMode)
 {
     // For MySQL the modifiers are added for each column not for all of the columns.
     return SerializeColumnAlterMode(alterMode);
 }
 public override string SerializeTableField(SQLTableField field, SQLTableFields.AlterModeType alterMode)
 {
     // if altering or creating a field append the AUTOINCREMENT. Field format: name datatype default nullable keytype AUTOINCREMENT
     if (alterMode != SQLTableFields.AlterModeType.Drop && field.AutoIncrements)
         return base.SerializeTableField(field, alterMode) + " AUTOINCREMENT";
     else
         return base.SerializeTableField(field, alterMode);
 }