Skip to content

Commit 8e60563

Browse files
committed
lint: double -> single quote
1 parent 42a8d04 commit 8e60563

File tree

2 files changed

+36
-33
lines changed

2 files changed

+36
-33
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.formatting.provider": "black"
3+
}

sqlalchemy_utils/view.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ def __init__(
2323

2424
@compiler.compiles(CreateView)
2525
def compile_create_materialized_view(element, compiler, **kw):
26-
return "CREATE {}{}VIEW {}{} AS {}".format(
27-
"OR REPLACE " if element.or_replace else "",
28-
"MATERIALIZED " if element.materialized else "",
29-
"IF NOT EXISTS " if element.if_not_exists else "",
26+
return 'CREATE {}{}VIEW {}{} AS {}'.format(
27+
'OR REPLACE ' if element.or_replace else '',
28+
'MATERIALIZED ' if element.materialized else '',
29+
'IF NOT EXISTS ' if element.if_not_exists else '',
3030
compiler.dialect.identifier_preparer.quote(element.name),
3131
compiler.sql_compiler.process(element.selectable, literal_binds=True),
3232
)
3333

3434

35-
@compiler.compiles(CreateView, "postgresql")
35+
@compiler.compiles(CreateView, 'postgresql')
3636
def compile_create_materialized_view_(element, compiler, **kw):
3737
"""
3838
CREATE [ OR REPLACE ] [ TEMP | TEMPORARY ] [ RECURSIVE ] VIEW name [ ( column_name [, ...] ) ]
@@ -51,16 +51,16 @@ def compile_create_materialized_view_(element, compiler, **kw):
5151
see https://www.postgresql.org/docs/current/sql-createview.html
5252
see https://www.postgresql.org/docs/current/sql-creatematerializedview.html
5353
"""
54-
return "CREATE {}{}VIEW {}{} AS {}".format(
55-
"OR REPLACE " if not element.materialized and element.or_replace else "",
56-
"MATERIALIZED " if element.materialized else "",
57-
"IF NOT EXISTS " if element.materialized and element.if_not_exists else "",
54+
return 'CREATE {}{}VIEW {}{} AS {}'.format(
55+
'OR REPLACE ' if not element.materialized and element.or_replace else '',
56+
'MATERIALIZED ' if element.materialized else '',
57+
'IF NOT EXISTS ' if element.materialized and element.if_not_exists else '',
5858
compiler.dialect.identifier_preparer.quote(element.name),
5959
compiler.sql_compiler.process(element.selectable, literal_binds=True),
6060
)
6161

6262

63-
@compiler.compiles(CreateView, "mysql")
63+
@compiler.compiles(CreateView, 'mysql')
6464
def compile_create_materialized_view_(element, compiler, **kw):
6565
"""
6666
CREATE
@@ -76,15 +76,15 @@ def compile_create_materialized_view_(element, compiler, **kw):
7676
NOTE mysql does not support materialized view
7777
"""
7878
if element.materialized:
79-
raise ValueError("mysql does not support materialized view!")
80-
return "CREATE {}VIEW {} AS {}".format(
81-
"OR REPLACE " if element.or_replace else "",
79+
raise ValueError('mysql does not support materialized view!')
80+
return 'CREATE {}VIEW {} AS {}'.format(
81+
'OR REPLACE ' if element.or_replace else '',
8282
compiler.dialect.identifier_preparer.quote(element.name),
8383
compiler.sql_compiler.process(element.selectable, literal_binds=True),
8484
)
8585

8686

87-
@compiler.compiles(CreateView, "mssql")
87+
@compiler.compiles(CreateView, 'mssql')
8888
def compile_create_materialized_view_(element, compiler, **kw):
8989
"""
9090
CREATE [ OR ALTER ] VIEW [ schema_name . ] view_name [ (column [ ,...n ] ) ]
@@ -103,15 +103,15 @@ def compile_create_materialized_view_(element, compiler, **kw):
103103
see https://docs.microsoft.com/en-us/sql/t-sql/statements/create-view-transact-sql?view=sql-server-ver15
104104
see https://docs.microsoft.com/en-us/sql/t-sql/statements/create-materialized-view-as-select-transact-sql?view=azure-sqldw-latest&viewFallbackFrom=sql-server-ver15
105105
"""
106-
return "CREATE {}{}VIEW {} AS {}".format(
107-
"OR ALTER " if not element.materialized and element.or_replace else "",
108-
"MATERIALIZED " if element.materialized else "",
106+
return 'CREATE {}{}VIEW {} AS {}'.format(
107+
'OR ALTER ' if not element.materialized and element.or_replace else '',
108+
'MATERIALIZED ' if element.materialized else '',
109109
compiler.dialect.identifier_preparer.quote(element.name),
110110
compiler.sql_compiler.process(element.selectable, literal_binds=True),
111111
)
112112

113113

114-
@compiler.compiles(CreateView, "snowflake")
114+
@compiler.compiles(CreateView, 'snowflake')
115115
def compile_create_materialized_view(element, compiler, **kw):
116116
"""
117117
CREATE [ OR REPLACE ] [ SECURE ] [ RECURSIVE ] VIEW [ IF NOT EXISTS ] <name>
@@ -140,10 +140,10 @@ def compile_create_materialized_view(element, compiler, **kw):
140140
see https://docs.snowflake.com/en/sql-reference/sql/create-view.html
141141
see https://docs.snowflake.com/en/sql-reference/sql/create-materialized-view.html
142142
"""
143-
return "CREATE {}{}VIEW {}{} AS {}".format(
144-
"OR REPLACE " if element.or_replace else "",
145-
"MATERIALIZED " if element.materialized else "",
146-
"IF NOT EXISTS " if element.if_not_exists else "",
143+
return 'CREATE {}{}VIEW {}{} AS {}'.format(
144+
'OR REPLACE ' if element.or_replace else '',
145+
'MATERIALIZED ' if element.materialized else '',
146+
'IF NOT EXISTS ' if element.if_not_exists else '',
147147
compiler.dialect.identifier_preparer.quote(element.name),
148148
compiler.sql_compiler.process(element.selectable, literal_binds=True),
149149
)
@@ -158,10 +158,10 @@ def __init__(self, name, materialized=False, cascade=True):
158158

159159
@compiler.compiles(DropView)
160160
def compile_drop_materialized_view(element, compiler, **kw):
161-
return "DROP {}VIEW IF EXISTS {} {}".format(
162-
"MATERIALIZED " if element.materialized else "",
161+
return 'DROP {}VIEW IF EXISTS {} {}'.format(
162+
'MATERIALIZED ' if element.materialized else '',
163163
compiler.dialect.identifier_preparer.quote(element.name),
164-
"CASCADE" if element.cascade else "",
164+
'CASCADE' if element.cascade else '',
165165
)
166166

167167

@@ -230,7 +230,7 @@ def create_materialized_view(
230230

231231
sa.event.listen(
232232
metadata,
233-
"after_create",
233+
'after_create',
234234
CreateView(
235235
name,
236236
selectable,
@@ -240,12 +240,12 @@ def create_materialized_view(
240240
),
241241
)
242242

243-
@sa.event.listens_for(metadata, "after_create")
243+
@sa.event.listens_for(metadata, 'after_create')
244244
def create_indexes(target, connection, **kw):
245245
for idx in table.indexes:
246246
idx.create(connection)
247247

248-
sa.event.listen(metadata, "before_drop", DropView(name, materialized=True))
248+
sa.event.listen(metadata, 'before_drop', DropView(name, materialized=True))
249249
return table
250250

251251

@@ -299,18 +299,18 @@ def create_view(
299299

300300
sa.event.listen(
301301
metadata,
302-
"after_create",
302+
'after_create',
303303
CreateView(
304304
name, selectable, if_not_exists=if_not_exists, or_replace=or_replace
305305
),
306306
)
307307

308-
@sa.event.listens_for(metadata, "after_create")
308+
@sa.event.listens_for(metadata, 'after_create')
309309
def create_indexes(target, connection, **kw):
310310
for idx in table.indexes:
311311
idx.create(connection)
312312

313-
sa.event.listen(metadata, "before_drop", DropView(name, cascade=cascade_on_drop))
313+
sa.event.listen(metadata, 'before_drop', DropView(name, cascade=cascade_on_drop))
314314
return table
315315

316316

@@ -327,8 +327,8 @@ def refresh_materialized_view(session, name, concurrently=False):
327327
# order to include newly-created/modified objects in the refresh.
328328
session.flush()
329329
session.execute(
330-
"REFRESH MATERIALIZED VIEW {}{}".format(
331-
"CONCURRENTLY " if concurrently else "",
330+
'REFRESH MATERIALIZED VIEW {}{}'.format(
331+
'CONCURRENTLY ' if concurrently else '',
332332
session.bind.engine.dialect.identifier_preparer.quote(name),
333333
)
334334
)

0 commit comments

Comments
 (0)