public void PutAndGetDecimalByColumnTypeTest() { var map = new TypeMap(); map.Put(DbType.Decimal, "NUMBER"); map.Put(DbType.Decimal, 18, "NUMBER($l, $s)"); Assert.AreEqual("NUMBER(11, 2)", map.Get(DbType.Decimal.WithSize(11, 2))); Assert.AreEqual("NUMBER(8, $s)", map.Get(DbType.Decimal.WithSize(8))); // will cause trouble }
public void PutAndGetDecimalTest() { var map = new TypeMap(); map.Put(DbType.Decimal, "NUMBER"); map.Put(DbType.Decimal, 18, "NUMBER($l, $s)"); Assert.AreEqual("NUMBER", map.Get(DbType.Decimal)); Assert.AreEqual("NUMBER(10, 5)", map.Get(DbType.Decimal, 10, 5)); Assert.AreEqual("NUMBER(7, $s)", map.Get(DbType.Decimal, 7)); // will cause trouble }
public void PutAndGetByColumnTypeTest2() { var map = new TypeMap(); map.Put(DbType.AnsiString, "VARCHAR($l)"); Assert.AreEqual("VARCHAR($l)", map.Get(new ColumnType(DbType.AnsiString))); // will cause trouble Assert.AreEqual("VARCHAR(100)", map.Get(DbType.AnsiString.WithSize(100))); Assert.AreEqual("VARCHAR(1000)", map.Get(DbType.AnsiString.WithSize(1000))); Assert.AreEqual("VARCHAR(10000)", map.Get(DbType.AnsiString.WithSize(10000))); }
public void PutAndGetByColumnTypeTest() { var map = new TypeMap(); map.Put(DbType.AnsiString, "TEXT"); map.Put(DbType.AnsiString, 255, "VARCHAR($l)"); map.Put(DbType.AnsiString, 65534, "LONGVARCHAR($l)"); Assert.AreEqual("TEXT", map.Get(new ColumnType(DbType.AnsiString))); // default Assert.AreEqual("VARCHAR(100)", map.Get(DbType.AnsiString.WithSize(100))); // 100 is in [0:255] Assert.AreEqual("LONGVARCHAR(1000)", map.Get(DbType.AnsiString.WithSize(1000))); // 100 is in [256:65534]) Assert.AreEqual("TEXT", map.Get(DbType.AnsiString.WithSize(100000))); // default }
public ColumnSqlBuilder AppendColumnType(bool identityNeedsType) { string type = column.IsIdentity && !identityNeedsType ? string.Empty : typeMap.Get(column.ColumnType); if (!string.IsNullOrEmpty(type)) { vals.Add(type); } return(this); }
protected virtual string GetSqlChangeColumnType(SchemaQualifiedObjectName table, string column, ColumnType columnType) { string columnTypeSql = typeMap.Get(columnType); return(FormatSql("ALTER TABLE {0:NAME} ALTER COLUMN {1:NAME} {2}", table, column, columnTypeSql)); }
public void PutAndGetTest2() { var map = new TypeMap(); map.Put(DbType.AnsiString, "VARCHAR($l)"); Assert.AreEqual("VARCHAR($l)", map.Get(DbType.AnsiString)); // will cause trouble Assert.AreEqual("VARCHAR(100)", map.Get(DbType.AnsiString, 100)); Assert.AreEqual("VARCHAR(1000)", map.Get(DbType.AnsiString, 1000)); Assert.AreEqual("VARCHAR(10000)", map.Get(DbType.AnsiString, 10000)); }
public void ReplacingWithDefaultScaleTest() { var map = new TypeMap(); map.Put(DbType.Xml, 20, "foo($l, $s)", 5); Assert.AreEqual("foo(12, 7)", map.Get(DbType.Xml, 12, 7)); Assert.AreEqual("foo(12, 5)", map.Get(DbType.Xml, 12)); }