Example #1
0
 public TableDiff(TableDefinition expected, TableDefinition actual)
 {
     Missing = expected.Columns.Where(x => actual.Columns.All(_ => _.Name != x.Name)).ToArray();
     Extras = actual.Columns.Where(x => expected.Columns.All(_ => _.Name != x.Name)).ToArray();
     Matched = expected.Columns.Intersect(actual.Columns).ToArray();
     Different = expected.Columns.Where(x => actual.HasColumn(x.Name) && !x.Equals(actual.Column(x.Name))).ToArray();
 }
        public when_generating_a_table_for_soft_deletes()
        {
            var mapping = DocumentMapping.For<Target>();
            mapping.DeleteStyle = DeleteStyle.SoftDelete;

            var schemaObjects = new DocumentSchemaObjects(mapping);

            theTable = schemaObjects.StorageTable();
        }
Example #3
0
        public void CreateTable(Type documentType, Type idType)
        {
            // TODO -- fancier later
            var table = new TableDefinition(TableNameFor(documentType), new TableColumn("id", TypeMappings.PgTypes[idType]));
            table.Columns.Add(new TableColumn("data", "jsonb NOT NULL"));

            table.Write(_writer);

            _writer.WriteLine();
        }
Example #4
0
        public SchemaObjects(Type documentType, TableDefinition table, ActualIndex[] actualIndices, FunctionBody function)
        {
            DocumentType = documentType;
            Table = table;
            Function = function;

            actualIndices.Each(x => ActualIndices.Add(x.Name, x));



        }
Example #5
0
        public when_deriving_the_table_definition_from_the_database_schema_Tests()
        {
            _schema = theStore.Schema;

            theMapping = _schema.MappingFor(typeof(User)).As<DocumentMapping>();
            theMapping.DuplicateField("UserName");

            _storage = _schema.StorageFor(typeof(User));

            theDerivedTable = _schema.DbObjects.TableSchema(theMapping);
        }
Example #6
0
        public SchemaObjects(Type documentType, TableDefinition table, ActualIndex[] actualIndices, string upsertFunction, List<string> drops)
        {
            DocumentType = documentType;
            Table = table;

            actualIndices.Each(x => ActualIndices.Add(x.Name, x));

            UpsertFunction = upsertFunction?.CanonicizeSql();

            FunctionDropStatements = drops;
        }
        public when_deriving_the_table_definition_from_the_database_schema_Tests()
        {
            ConnectionSource.CleanBasicDocuments();
            _schema = _container.GetInstance<DocumentSchema>();

            theMapping = _schema.MappingFor(typeof(User));
            theMapping.DuplicateField("UserName");


            _storage = _schema.StorageFor(typeof(User));

            theDerivedTable = _schema.TableSchema(theMapping.TableName);
        }
Example #8
0
 protected bool Equals(TableDefinition other)
 {
     return Columns.OrderBy(x => x.Name).SequenceEqual(other.Columns.OrderBy(x => x.Name)) && Equals(PrimaryKey, other.PrimaryKey) && Table.Equals(other.Table);
 }
Example #9
0
 protected bool Equals(TableDefinition other)
 {
     return Columns.OrderBy(x => x.Name).SequenceEqual(other.Columns.OrderBy(x => x.Name)) && Equals(PrimaryKey, other.PrimaryKey) && string.Equals(QualifiedName, other.QualifiedName);
 }
Example #10
0
 protected bool Equals(TableDefinition other)
 {
     return Columns.SequenceEqual(other.Columns) && Equals(PrimaryKey, other.PrimaryKey) && string.Equals(Name, other.Name);
 }
Example #11
0
 protected bool Equals(TableDefinition other)
 {
     return(Columns.OrderBy(x => x.Name).SequenceEqual(other.Columns.OrderBy(x => x.Name)) && Equals(PrimaryKey, other.PrimaryKey) && string.Equals(Name, other.Name));
 }
        // take in schema so that you
        // can do foreign keys
        public TableDefinition ToTable(IDocumentSchema schema)
        {
            // TODO -- blow up if no IdMember or no TableName

            var pgIdType = TypeMappings.PgTypes[IdMember.GetMemberType()];
            var table = new TableDefinition(TableName, new TableColumn("id", pgIdType));
            table.Columns.Add(new TableColumn("data", "jsonb NOT NULL"));

            return table;
        }