Ejemplo n.º 1
0
 def setUp(self):
     ensure_db()
     table_spec = {
         "columns": [{
             "name": "id",
             "type": "integer",
             "primary_key": True,
             "serial": True
         }, {
             "name": '"character-varying_name"',
             "type": "character varying"
         }, {
             "name": '"varchar-name"',
             "type": "varchar(28)"
         }, {
             "name": 'char_name',
             "type": "char(10)"
         }, {
             "name": '"text-name"',
             "type": "text"
         }],
         "name":
         TestStringTableWithPK.table_name
     }
     ensure_test_table(table_spec)
Ejemplo n.º 2
0
    def setUp(self):
        ensure_db('postgres')
        with get_test_connection('postgres') as conn:
            with conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as cur:
                cur.execute(
                    'DROP MATERIALIZED VIEW IF EXISTS "LIKE CHICKEN TIMES"')
        table_spec = {
            "columns": [{
                "name": 'our_int_array_pk',
                "type": "integer[]",
                "primary_key": True
            }, {
                "name": 'our_text_array',
                "type": "text[]"
            }],
            "name":
            TestArraysLikeTable.table_name
        }
        ensure_test_table(table_spec)

        with get_test_connection('postgres') as conn:
            with conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as cur:
                create_sql = "CREATE MATERIALIZED VIEW {} AS SELECT * FROM {}\n".format(
                    quote_ident(TestArraysLikeTable.like_table_name, cur),
                    quote_ident(TestArraysLikeTable.table_name, cur))

                cur.execute(create_sql)
Ejemplo n.º 3
0
 def setUp(self):
     ensure_db('dev')
     ensure_db('postgres')
     table_spec = {
         "columns": [{
             "name": 'our_date',
             "type": "DATE",
             "primary_key": True
         }, {
             "name": 'our_ts',
             "type": "TIMESTAMP"
         }, {
             "name": 'our_ts_tz',
             "type": "TIMESTAMP WITH TIME ZONE"
         }, {
             "name": 'our_time',
             "type": "TIME"
         }, {
             "name": 'our_time_tz',
             "type": "TIME WITH TIME ZONE"
         }],
         "name":
         TestMultiDB.table_name
     }
     ensure_test_table(table_spec, 'dev')
     ensure_test_table(table_spec, 'postgres')
Ejemplo n.º 4
0
 def setup(self):
     table_spec = {
         "columns": [{
             "name": "string",
             "type": "STRING"
         }, {
             "name": "integer",
             "type": "INTEGER"
         }, {
             "name": "time_created",
             "type": "TIMESTAMP"
         }, {
             "name": "object",
             "type": "VARIANT"
         }, {
             "name": "boolean",
             "type": "BOOLEAN"
         }, {
             "name": "number",
             "type": "NUMBER"
         }, {
             "name": "date_created",
             "type": "DATE"
         }],
         "schema":
         TestMergeTable.schema_name,
         "name":
         TestMergeTable.table_name
     }
     con = get_test_connection()
     ensure_test_table(con, table_spec)
Ejemplo n.º 5
0
 def setUp(self):
     table_spec = {
         "columns": [{
             "name": 'our_secrets',
             "type": "json"
         }, {
             "name": 'our_secrets_b',
             "type": "jsonb"
         }],
         "name":
         TestJsonTables.table_name
     }
     ensure_test_table(table_spec)
Ejemplo n.º 6
0
 def setUp(self):
     table_spec = {
         "columns": [{
             "name": 'our_bool',
             "type": "boolean"
         }, {
             "name": 'our_bit',
             "type": "bit"
         }],
         "name":
         TestBoolsAndBits.table_name
     }
     ensure_test_table(table_spec)
Ejemplo n.º 7
0
 def setUp(self):
     table_spec = {
         "columns": [{
             "name": 'our_pk',
             "type": "uuid",
             "primary_key": True
         }, {
             "name": 'our_uuid',
             "type": "uuid"
         }],
         "name":
         TestUUIDTables.table_name
     }
     ensure_test_table(table_spec)
Ejemplo n.º 8
0
 def setUp(self):
     ensure_db()
     table_spec = {
         "columns": [{
             "name": 'our_money_pk',
             "type": "money",
             "primary_key": True
         }, {
             "name": 'our_money',
             "type": "money"
         }],
         "name":
         TestHStoreTable.table_name
     }
     ensure_test_table(table_spec)
Ejemplo n.º 9
0
 def setUp(self):
     ensure_db()
     table_spec = {
         "columns": [{
             "name": 'our_int_array_pk',
             "type": "integer[]",
             "primary_key": True
         }, {
             "name": 'our_string_array',
             "type": "varchar[]"
         }],
         "name":
         TestHStoreTable.table_name
     }
     ensure_test_table(table_spec)
Ejemplo n.º 10
0
 def setUp(self):
     table_spec = {
         "columns": [{
             "name": 'our_decimal',
             "type": "numeric",
             "primary_key": True
         }, {
             "name": 'our_decimal_10_2',
             "type": "decimal(10,2)"
         }, {
             "name": 'our_decimal_38_4',
             "type": "decimal(38,4)"
         }],
         "name":
         TestDecimalPK.table_name
     }
     ensure_test_table(table_spec)
Ejemplo n.º 11
0
 def setUp(self):
     table_spec = {
         "columns": [{
             "name": 'our_float',
             "type": "float",
             "primary_key": True
         }, {
             "name": 'our_real',
             "type": "real"
         }, {
             "name": 'our_double',
             "type": "double precision"
         }],
         "name":
         TestFloatTablePK.table_name
     }
     ensure_test_table(table_spec)
Ejemplo n.º 12
0
    def setUp(self):
        ensure_db()
        table_spec = {
            "columns": [{
                "name": "id",
                "type": "integer",
                "serial": True
            }, {
                "name": 'size integer',
                "type": "integer",
                "quoted": True
            }, {
                "name": 'size smallint',
                "type": "smallint",
                "quoted": True
            }, {
                "name": 'size bigint',
                "type": "bigint",
                "quoted": True
            }],
            "name":
            TestColumnGrants.table_name
        }
        ensure_test_table(table_spec)

        with get_test_connection() as conn:
            cur = conn.cursor()

            sql = """ DROP USER IF EXISTS {} """.format(
                self.user, self.password)
            LOGGER.info(sql)
            cur.execute(sql)

            sql = """ CREATE USER {} WITH PASSWORD '{}' """.format(
                self.user, self.password)
            LOGGER.info(sql)
            cur.execute(sql)

            sql = """ GRANT SELECT ("id") ON "{}" TO {}""".format(
                TestColumnGrants.table_name, self.user)
            LOGGER.info("running sql: {}".format(sql))
            cur.execute(sql)
Ejemplo n.º 13
0
    def setUp(self):
        ensure_db()
        table_spec = {
            "columns": [{
                "name": 'our_mood_enum_pk',
                "type": "mood_enum",
                "primary_key": True
            }, {
                "name": 'our_mood_enum',
                "type": "mood_enum"
            }],
            "name":
            TestHStoreTable.table_name
        }
        with get_test_connection() as conn:
            cur = conn.cursor()
            cur.execute("""     DROP TYPE IF EXISTS mood_enum CASCADE """)
            cur.execute(
                """     CREATE TYPE mood_enum AS ENUM ('sad', 'ok', 'happy'); """
            )

        ensure_test_table(table_spec)
 def setUp(self):
     ensure_db()
     table_spec_1 = {
         "columns": [{
             "name": "id",
             "type": "serial",
             "primary_key": True
         }, {
             "name": 'name',
             "type": "character varying"
         }, {
             "name": 'colour',
             "type": "character varying"
         }],
         "name":
         'COW'
     }
     ensure_test_table(table_spec_1)
     global COW_RECORD_COUNT
     COW_RECORD_COUNT = 0
     global CAUGHT_MESSAGES
     CAUGHT_MESSAGES.clear()
Ejemplo n.º 15
0
 def setUp(self):
     table_spec = {
         "columns": [{
             "name": "id",
             "type": "integer",
             "serial": True
         }, {
             "name": 'size integer',
             "type": "integer",
             "quoted": True
         }, {
             "name": 'size smallint',
             "type": "smallint",
             "quoted": True
         }, {
             "name": 'size bigint',
             "type": "bigint",
             "quoted": True
         }],
         "name":
         TestIntegerTable.table_name
     }
     ensure_test_table(table_spec)
Ejemplo n.º 16
0
    def setUp(self):
        ensure_db()
        table_spec = {
            "columns": [{
                "name": 'our_pk',
                "type": "hstore",
                "primary_key": True
            }, {
                "name": 'our_hstore',
                "type": "hstore"
            }],
            "name":
            TestHStoreTable.table_name
        }
        with get_test_connection() as conn:
            cur = conn.cursor()
            cur.execute(
                """ SELECT installed_version FROM pg_available_extensions WHERE name = 'hstore' """
            )
            if cur.fetchone()[0] is None:
                cur.execute(""" CREATE EXTENSION hstore; """)

        ensure_test_table(table_spec)
Ejemplo n.º 17
0
 def setUp(self):
     table_spec = {
         "columns": [{
             "name": 'our_date',
             "type": "DATE",
             "primary_key": True
         }, {
             "name": 'our_ts',
             "type": "TIMESTAMP"
         }, {
             "name": 'our_ts_tz',
             "type": "TIMESTAMP WITH TIME ZONE"
         }, {
             "name": 'our_time',
             "type": "TIME"
         }, {
             "name": 'our_time_tz',
             "type": "TIME WITH TIME ZONE"
         }],
         "name":
         TestDatesTablePK.table_name
     }
     ensure_test_table(table_spec)
Ejemplo n.º 18
0
    def setUp(self):
        ensure_db()
        with get_test_connection() as conn:
            cur = conn.cursor()
            table_spec = {"columns": [{"name": "interval_col",   "type": "INTERVAL"},
                                      {"name": "bit_string_col", "type": "bit(5)"},
                                      {"name": "bytea_col",      "type": "bytea"},
                                      {"name": "point_col",      "type": "point"},
                                      {"name": "line_col",      "type": "line"},
                                      {"name": "lseg_col",      "type": "lseg"},
                                      {"name": "box_col",      "type": "box"},
                                      {"name": "polygon_col",      "type": "polygon"},
                                      {"name": "circle_col",      "type": "circle"},
                                      {"name": "xml_col",      "type": "xml"},
                                      {"name": "composite_col",      "type": "person_composite"},
                                      {"name": "int_range_col",      "type": "int4range"},
            ],
                          "name": Unsupported.table_name}
            with get_test_connection() as conn:
                cur = conn.cursor()
                cur.execute("""     DROP TYPE IF EXISTS person_composite CASCADE """)
                cur.execute("""     CREATE TYPE person_composite AS (age int, name text) """)

            ensure_test_table(table_spec)