예제 #1
0
파일: TableDiff.cs 프로젝트: nieve/marten
 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();
        }
예제 #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();
        }
예제 #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));



        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
 }
예제 #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);
 }
예제 #10
0
 protected bool Equals(TableDefinition other)
 {
     return Columns.SequenceEqual(other.Columns) && Equals(PrimaryKey, other.PrimaryKey) && string.Equals(Name, other.Name);
 }
예제 #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));
 }
예제 #12
0
        // 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;
        }