Skip to content

Commit

Permalink
fix: correct all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Net-Mist committed Oct 23, 2023
1 parent 2d6a576 commit e1748de
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion clickhouse_sqlalchemy/drivers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def get_view_names(self, connection, schema=None, **kw):
rows = self._execute(connection, query, database=database)
return [row.name for row in rows]

def has_table(self, connection, table_name, schema=None):
def has_table(self, connection, table_name, schema=None, **kw):
quote = self._quote_table_name
if schema:
qualified_name = quote(schema) + '.' + quote(table_name)
Expand Down
2 changes: 2 additions & 0 deletions clickhouse_sqlalchemy/drivers/compilers/ddlcompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

class ClickHouseDDLCompiler(compiler.DDLCompiler):
def _get_default_string(self, default, name):
if default == "":
return "''"
sa_util.assert_arg_type(
default, (String, ClauseElement, TextClause), name
)
Expand Down
4 changes: 3 additions & 1 deletion clickhouse_sqlalchemy/drivers/compilers/sqlcompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,9 @@ def visit_update(self, update_stmt, **kw):

text += table_text
text += " UPDATE "
text += ", ".join(expr + "=" + value for c, expr, value, _ in crud_params.single_params)
text += ", ".join(
expr + "=" + value for c,
expr, value, _ in crud_params.single_params)

if update_stmt._where_criteria:
t = self._generate_delimited_and_list(
Expand Down
3 changes: 2 additions & 1 deletion clickhouse_sqlalchemy/drivers/native/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
class ClickHouseExecutionContext(ClickHouseExecutionContextBase):
def pre_exec(self):
# Always do executemany on INSERT with VALUES clause.
if self.isinsert and self.compiled.statement.select is None:
if (self.isinsert and self.compiled.statement.select is None and
self.parameters != [{}]):
self.execute_style = ExecuteStyle.EXECUTEMANY


Expand Down
2 changes: 1 addition & 1 deletion clickhouse_sqlalchemy/ext/clauses.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class LimitByClause:

def __init__(self, by_clauses, limit, offset):
self.by_clauses = ClauseList(
*by_clauses, _literal_as_text=roles.ByOfRole
*by_clauses, _literal_as_text_role=roles.ByOfRole
)
self.offset = _offset_or_limit_clause(offset)
self.limit = _offset_or_limit_clause(limit)
Expand Down
7 changes: 3 additions & 4 deletions clickhouse_sqlalchemy/orm/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,14 @@ def limit_by(self, by_clauses, limit, offset=None):
self._limit_by = LimitByClause(by_clauses, limit, offset)
return self

def join(self, *props, **kwargs):
def join(self, target, onclause=None, **kwargs):
spec = {
'type': kwargs.pop('type', None),
'strictness': kwargs.pop('strictness', None),
'distribution': kwargs.pop('distribution', None)
}
rv = super(Query, self).join(*props, **kwargs)

x = rv._legacy_setup_joins[-1]
rv = super().join(target, onclause, **kwargs)
x = rv._setup_joins[-1]
x_spec = dict(spec)
# use 'full' key to pass extra flags
x_spec['full'] = x[-1]['full']
Expand Down
4 changes: 2 additions & 2 deletions clickhouse_sqlalchemy/sql/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def join(self, right, onclause=None, isouter=False, full=False,

def select(self, whereclause=None, **params):
if whereclause:
return Select._create(self, whereclause, **params)
return Select._create(self, **params)
return Select(self, whereclause, **params)
return Select(self, **params)

@classmethod
def _make_from_standard(cls, std_table, _extend_on=None):
Expand Down
2 changes: 1 addition & 1 deletion tests/engines/test_reflection.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def test_create_reflected(self):

def test_disable_engine_reflection(self):
engine = self.session.connection().engine
url = str(engine.url)
url = engine.url.render_as_string(hide_password=False)
prefix = 'clickhouse+{}://'.format(engine.driver)
if not url.startswith(prefix):
url = prefix + url.split('://')[1]
Expand Down

0 comments on commit e1748de

Please sign in to comment.