Beispiel #1
0
    def test_sql_create_from_json(self):
        """
        Build the column part of index
        """
        idx = {'name': 'compo1',
               'table': 'editors',
               'columns': ['id', 'name'],
               'tablespace': 'ssd1'}

        res = " ".join(["CREATE INDEX CONCURRENTLY compo1",
                        "ON editors (id,name)",
                        "TABLESPACE ssd1"])
        self.assertEqual(util.sql_create_from_json(idx), res)
Beispiel #2
0
    def test_sql_create_from_json_opclass(self):
        """
        Build the column part of index with an operator class
        """
        idx = {'name': 'compo1',
               'table': 'editors',
               'columns': [{'name': 'gist_trgm_ops'},
                           {'species': 'gist_trgm_ops'}],
               'using': 'GIST'}

        res = " ".join(["CREATE INDEX CONCURRENTLY compo1",
                        "ON editors USING GIST",
                        "(name gist_trgm_ops,species gist_trgm_ops)"])
        self.assertEqual(util.sql_create_from_json(idx), res)