Skip to content

Commit 9142480

Browse files
authored
Merge pull request #3 from exiorrealty/feat/auto-execute
Feat/auto execute
2 parents f552251 + 798a16e commit 9142480

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

sql_db_utils/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.1.0"
1+
__version__ = "1.1.1"

sql_db_utils/sql_extras.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def compile_create_prefixed_id_function(element: CreatePrefixedIdFunction, _comp
127127
next_val INTEGER;
128128
BEGIN
129129
next_val := nextval(seq_name);
130-
RETURN prefix || next_val;
130+
RETURN prefix || '_' || next_val;
131131
END;
132132
$$ LANGUAGE plpgsql;
133133
"""
@@ -148,7 +148,17 @@ def compile_create_suffixed_id_function(element: CreateSuffixedIdFunction, _comp
148148
next_val INTEGER;
149149
BEGIN
150150
next_val := nextval(seq_name);
151-
RETURN next_val || suffix;
151+
RETURN next_val || '_' || suffix;
152152
END;
153153
$$ LANGUAGE plpgsql;
154154
"""
155+
156+
157+
class CreateSchema(DDLElement):
158+
def __init__(self, schema_name: str):
159+
self.schema_name = schema_name
160+
161+
162+
@compiler.compiles(CreateSchema)
163+
def compile_create_schema(element: CreateSchema, compiler: Any, **kw: Any) -> str:
164+
return f"CREATE SCHEMA IF NOT EXISTS {element.schema_name};"

0 commit comments

Comments
 (0)