public void try_command_runner() { var builder = new SchemaBuilder(); builder.CreateTable(typeof(SchemaBuilderTests.MySpecialDocument), typeof(Guid)); builder.DefineUpsert(typeof (SchemaBuilderTests.MySpecialDocument), typeof(Guid)); var id = Guid.NewGuid(); using (var runner = new CommandRunner(ConnectionSource.ConnectionString)) { runner.Execute(builder.ToSql()); /* runner.Execute("mt_upsert_myspecialdocument", command => { command.Parameters.Add("docId", NpgsqlDbType.Uuid).Value = id; command.Parameters.Add("doc", NpgsqlDbType.Json).Value = "{\"id\":\"1\"}"; }); runner.Execute("mt_upsert_myspecialdocument", command => { command.Parameters.Add("docId", NpgsqlDbType.Uuid).Value = id; command.Parameters.Add("doc", NpgsqlDbType.Json).Value = "{\"id\":\"2\"}"; }); * */ //runner.DescribeSchema(); runner.SchemaFunctionNames().Each(x => Debug.WriteLine(x)); } }
public void write_upsert_sql() { var builder = new SchemaBuilder(); builder.DefineUpsert(typeof(MySpecialDocument)); var sql = builder.ToSql(); sql.ShouldContain("INSERT INTO mt_doc_MySpecialDocument"); sql.ShouldContain("CREATE OR REPLACE FUNCTION mt_upsert_MySpecialDocument"); }
public void write_document_table() { var builder = new SchemaBuilder(); builder.CreateTable(typeof(MySpecialDocument)); var sql = builder.ToSql(); sql.ShouldContain("CREATE TABLE mt_doc_MySpecialDocument"); sql.ShouldContain("jsonb NOT NULL"); }
public IDocumentStorage StorageFor(Type documentType) { return _documentTypes.GetOrAdd(documentType, type => { var storage = DocumentStorageBuilder.Build(type); var builder = new SchemaBuilder(); storage.InitializeSchema(builder); _runner.Execute(builder.ToSql()); return storage; }); }
public IDocumentStorage StorageFor(Type documentType) { return _documentTypes.GetOrAdd(documentType, type => { // TODO -- will need to get fancier later when we stop requiring IDocument var storage = typeof (DocumentStorage<>).CloseAndBuildAs<IDocumentStorage>(documentType); var builder = new SchemaBuilder(); storage.InitializeSchema(builder); _runner.Value.Execute(builder.ToSql()); return storage; }); }