public void CreateTable() { _storage.EnterFluidMode(); var data = new Dictionary <string, object> { { "p1", null }, { "p2", 1 }, { "p3", 1000 }, { "p4", Int64.MaxValue }, { "p5", 3.14 }, { "p6", "abc" }, { "p7", "".PadRight(37, 'a') }, { "p8", "".PadRight(192, 'a') }, { "p9", DateTime.Now }, { "p10", new byte[0] } }; _storage.Store("foo", data); var cols = _storage.GetSchema()["foo"]; Assert.DoesNotContain("p1", cols.Keys); Assert.Equal(MariaDbDetails.RANK_INT8, cols["p2"]); Assert.Equal(MariaDbDetails.RANK_INT32, cols["p3"]); Assert.Equal(MariaDbDetails.RANK_INT64, cols["p4"]); Assert.Equal(MariaDbDetails.RANK_DOUBLE, cols["p5"]); Assert.Equal(MariaDbDetails.RANK_TEXT_36, cols["p6"]); Assert.Equal(MariaDbDetails.RANK_TEXT_191, cols["p7"]); Assert.Equal(MariaDbDetails.RANK_TEXT_MAX, cols["p8"]); Assert.Equal(MariaDbDetails.RANK_STATIC_DATETIME, cols["p9"]); Assert.Equal(MariaDbDetails.RANK_STATIC_BLOB, cols["p10"]); }
public static void CheckLongToDouble(IDatabaseAccess db, DatabaseStorage storage) { storage.EnterFluidMode(); var bigLong = Int64.MinValue + 12345; var longID = storage.Store("foo", MakeRow("p", bigLong)); storage.Store("foo", MakeRow("p", Math.PI)); Assert.Equal(bigLong, db.Cell <long>(false, "select p from foo where id = {0}", longID)); }
public static void CheckStoringNull(DatabaseStorage storage) { storage.EnterFluidMode(); var row = MakeRow("p", 1); var id = storage.Store("foo", row); row = storage.Load("foo", id); row["p"] = null; storage.Store("foo", row); row = storage.Load("foo", id); Assert.Null(row["p"]); }
public static void CheckCustomRank_MissingColumn(IDatabaseAccess db, DatabaseStorage storage) { storage.EnterFluidMode(); var row = MakeRow("a", new object()); // Try create table AssertCannotAddColumn(Record.Exception(delegate() { storage.Store("foo1", row); })); storage.Store("foo2", MakeRow("b", 1)); // Try add column AssertCannotAddColumn(Record.Exception(delegate() { storage.Store("foo2", row); })); }
public static void CheckDateTimeQueries(IDatabaseAccess db, DatabaseStorage storage) { storage.EnterFluidMode(); var dateTime = SAMPLE_DATETIME; var date = SAMPLE_DATETIME.Date; storage.Store("foo", MakeRow("d", date)); storage.Store("foo", MakeRow("d", dateTime)); Assert.Equal(2, db.Cell<int>(false, "select count(*) from foo where d = {0} or d = {1}", date, dateTime)); db.Exec("delete from foo"); for(var i = -2; i <= 2; i++) storage.Store("foo", MakeRow("d", date.AddDays(i))); Assert.Equal(3, db.Cell<int>(false, "select count(*) from foo where d between {0} and {1}", date.AddDays(-1), date.AddDays(1))); Assert.Equal(date, db.Cell<DateTime>(false, "select d from foo where d = {0}", date)); }
public static void CheckDateTimeQueries(IDatabaseAccess db, DatabaseStorage storage) { storage.EnterFluidMode(); var dateTime = SAMPLE_DATETIME; var date = SAMPLE_DATETIME.Date; storage.Store("foo", MakeRow("d", date)); storage.Store("foo", MakeRow("d", dateTime)); Assert.Equal(2, db.Cell <int>(false, "select count(*) from foo where d = {0} or d = {1}", date, dateTime)); db.Exec("delete from foo"); for (var i = -2; i <= 2; i++) { storage.Store("foo", MakeRow("d", date.AddDays(i))); } Assert.Equal(3, db.Cell <int>(false, "select count(*) from foo where d between {0} and {1}", date.AddDays(-1), date.AddDays(1))); Assert.Equal(date, db.Cell <DateTime>(false, "select d from foo where d = {0}", date)); }
public void CreateTable() { _storage.EnterFluidMode(); var data = new Dictionary <string, object> { { "p1", null }, { "p2", true }, { "p3", 1 }, { "p4", Int64.MaxValue }, { "p5", 3.14 }, { "p6", Decimal.MaxValue }, { "p7", UInt64.MaxValue }, { "p8", "abc" }, { "p9", DateTime.Now }, { "p10", DateTimeOffset.Now }, { "p11", Guid.NewGuid() }, { "p12", new byte[0] } }; _storage.Store("foo", data); var cols = _storage.GetSchema()["foo"]; Assert.DoesNotContain("p1", cols.Keys); Assert.Equal(PgSqlDetails.RANK_BOOLEAN, cols["p2"]); Assert.Equal(PgSqlDetails.RANK_INT32, cols["p3"]); Assert.Equal(PgSqlDetails.RANK_INT64, cols["p4"]); Assert.Equal(PgSqlDetails.RANK_DOUBLE, cols["p5"]); Assert.Equal(PgSqlDetails.RANK_NUMERIC, cols["p6"]); Assert.Equal(PgSqlDetails.RANK_NUMERIC, cols["p7"]); Assert.Equal(PgSqlDetails.RANK_TEXT, cols["p8"]); Assert.Equal(PgSqlDetails.RANK_STATIC_DATETIME, cols["p9"]); Assert.Equal(PgSqlDetails.RANK_STATIC_DATETIME_OFFSET, cols["p10"]); Assert.Equal(PgSqlDetails.RANK_STATIC_GUID, cols["p11"]); Assert.Equal(PgSqlDetails.RANK_STATIC_BLOB, cols["p12"]); }
public void Check(object before, object after) { var id = _storage.Store("foo", new Dictionary <string, object> { { "p", before } }); try { var loaded = _storage.Load("foo", id); Assert.Equal(after, loaded.GetSafe("p")); if (after != null) { Assert.Equal(after.GetType(), loaded["p"].GetType()); } } finally { _db.Exec("drop table foo"); _storage.InvalidateSchema(); } }
public static void CheckCompoundKey(DatabaseStorage storage, KeyUtil keys) { storage.EnterFluidMode(); keys.RegisterKey("foo", new[] { "k1", "k2" }, null); var row = MakeRow( "k1", "text", "k2", Guid.NewGuid(), "v", "hello" ); var id = storage.Store("foo", row) as CompoundKey; Assert.Equal(row["k1"], id["k1"]); Assert.Equal(row["k2"], id["k2"]); row = storage.Load("foo", id); Assert.Equal("hello", row["v"]); }
public void CreateTable() { _storage.EnterFluidMode(); var data = new Dictionary <string, object> { { "p1", null }, { "p2", 1 }, { "p3", -1 }, { "p4", Int64.MaxValue }, { "p5", 3.14 }, { "p6", "abcdfgh" }, { "p7_16", "".PadRight(9, 'a') }, { "p7_32", "".PadRight(17, 'a') }, { "p7_64", "".PadRight(33, 'a') }, { "p7_128", "".PadRight(65, 'a') }, { "p7_256", "".PadRight(129, 'a') }, { "p7_512", "".PadRight(257, 'a') }, { "p7_4k", "".PadRight(513, 'a') }, { "p8", "".PadRight(4001, 'a') }, { "p9", DateTime.Now }, { "p10", DateTimeOffset.Now }, { "p11", Guid.NewGuid() }, { "p12", new byte[0] } }; _storage.Store("foo", data); var cols = _storage.GetSchema()["foo"]; Assert.DoesNotContain("p1", cols.Keys); Assert.Equal(MsSqlDetails.RANK_BYTE, cols["p2"]); Assert.Equal(MsSqlDetails.RANK_INT32, cols["p3"]); Assert.Equal(MsSqlDetails.RANK_INT64, cols["p4"]); Assert.Equal(MsSqlDetails.RANK_DOUBLE, cols["p5"]); Assert.Equal(MsSqlDetails.RANK_TEXT_8, cols["p6"]); Assert.Equal(MsSqlDetails.RANK_TEXT_16, cols["p7_16"]); Assert.Equal(MsSqlDetails.RANK_TEXT_32, cols["p7_32"]); Assert.Equal(MsSqlDetails.RANK_TEXT_64, cols["p7_64"]); Assert.Equal(MsSqlDetails.RANK_TEXT_128, cols["p7_128"]); Assert.Equal(MsSqlDetails.RANK_TEXT_256, cols["p7_256"]); Assert.Equal(MsSqlDetails.RANK_TEXT_512, cols["p7_512"]); Assert.Equal(MsSqlDetails.RANK_TEXT_4000, cols["p7_4k"]); Assert.Equal(MsSqlDetails.RANK_TEXT_MAX, cols["p8"]); Assert.Equal(MsSqlDetails.RANK_STATIC_DATETIME, cols["p9"]); Assert.Equal(MsSqlDetails.RANK_STATIC_DATETIME_OFFSET, cols["p10"]); Assert.Equal(MsSqlDetails.RANK_STATIC_GUID, cols["p11"]); Assert.Equal(MsSqlDetails.RANK_STATIC_BLOB, cols["p12"]); }
public static void CheckGuidQuery(IDatabaseAccess db, DatabaseStorage storage) { storage.EnterFluidMode(); storage.Store("foo", MakeRow("g", SAMPLE_GUID)); Assert.Equal(SAMPLE_GUID, db.Cell <Guid>(false, "select g from foo where g = {0}", SAMPLE_GUID)); }
public static void CheckGuidQuery(IDatabaseAccess db, DatabaseStorage storage) { storage.EnterFluidMode(); storage.Store("foo", MakeRow("g", SAMPLE_GUID)); Assert.Equal(SAMPLE_GUID, db.Cell<Guid>(false, "select g from foo where g = {0}", SAMPLE_GUID)); }
public void StoreToGoodTable() { _db.Exec("create table kind1 (id integer primary key, p1, p2)"); var id = _storage.Store("kind1", SharedChecks.MakeRow( "p1", 123, "p2", "hello" )); var row = _db.Row(true, "select * from kind1"); Assert.Equal(123L, row["p1"]); Assert.Equal("hello", row["p2"]); Assert.Equal(id, row["id"]); Assert.Equal(id, _storage.Store("kind1", SharedChecks.MakeRow( "id", id, "p1", -1, "p2", "see you" ))); row = _db.Row(true, "select * from kind1"); Assert.Equal(-1L, row["p1"]); Assert.Equal("see you", row["p2"]); }
public static void CheckLongToDouble(IDatabaseAccess db, DatabaseStorage storage) { storage.EnterFluidMode(); var bigLong = Int64.MinValue + 12345; var longID = storage.Store("foo", MakeRow("p", bigLong)); storage.Store("foo", MakeRow("p", Math.PI)); Assert.Equal(bigLong, db.Cell<long>(false, "select p from foo where id = {0}", longID)); }