-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: support create <object> clone, close #313 * fix: allow qualified and quoted identifiers in create stmt
- Loading branch information
Showing
7 changed files
with
95 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from functools import partial | ||
|
||
from sqlfmt import actions | ||
from sqlfmt.rule import Rule | ||
from sqlfmt.rules.common import CREATE_CLONABLE, group | ||
from sqlfmt.rules.core import CORE | ||
from sqlfmt.token import TokenType | ||
|
||
CLONE = [ | ||
*CORE, | ||
Rule( | ||
name="unterm_keyword", | ||
priority=1300, | ||
pattern=group(CREATE_CLONABLE, r"clone") + group(r"\W", r"$"), | ||
action=partial(actions.add_node_to_buffer, token_type=TokenType.UNTERM_KEYWORD), | ||
), | ||
Rule( | ||
name="word_operator", | ||
priority=1500, | ||
pattern=group( | ||
r"at", | ||
r"before", | ||
) | ||
+ group(r"\W", r"$"), | ||
action=partial(actions.add_node_to_buffer, token_type=TokenType.WORD_OPERATOR), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
create database mytestdb_clone clone mytestdb; | ||
create schema mytestschema_clone_restore clone testschema before (timestamp => to_timestamp(40*365*86400)); | ||
create table orders_clone_restore clone orders at (timestamp => to_timestamp_tz('04/05/2013 01:02:03', 'mm/dd/yyyy hh24:mi:ss')); | ||
CREATE TABLE ORDERS_CLONE_RESTORE clone orders before (statement => '8e5d0ca9-005e-44e6-b858-a8f5b37c5726'); | ||
)))))__SQLFMT_OUTPUT__((((( | ||
create database mytestdb_clone | ||
clone mytestdb | ||
; | ||
create schema mytestschema_clone_restore | ||
clone testschema before (timestamp => to_timestamp(40 * 365 * 86400)) | ||
; | ||
create table orders_clone_restore | ||
clone | ||
orders | ||
at (timestamp => to_timestamp_tz('04/05/2013 01:02:03', 'mm/dd/yyyy hh24:mi:ss')) | ||
; | ||
create table orders_clone_restore | ||
clone orders before (statement => '8e5d0ca9-005e-44e6-b858-a8f5b37c5726') | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters