t-sql 4.2.0__tar.gz → 4.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {t_sql-4.2.0 → t_sql-4.2.1}/PKG-INFO +1 -1
- {t_sql-4.2.0 → t_sql-4.2.1}/pyproject.toml +1 -1
- {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_query_builder.py +55 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/tsql/__init__.py +2 -2
- {t_sql-4.2.0 → t_sql-4.2.1}/.dockerignore +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/.github/workflows/publish.yml +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/.github/workflows/test.yml +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/.gitignore +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/Dockerfile +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/LICENSE +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/README.md +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/compose.yaml +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/context7.json +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/pytest.ini +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_alembic_integration.py +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_asyncpg_integration.py +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_different_object_types.py +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_escaped.py +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_escaped_binary_hex.py +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_helper_functions.py +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_injection_edge_cases.py +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_injection_protection_validation.py +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_injections_for_escaped.py +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_mysql_integration.py +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_parameter_names.py +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_sqlalchemy_integration.py +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_sqlite_integration.py +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_styles.py +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_tsql.py +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/tsql/query_builder.py +0 -0
- {t_sql-4.2.0 → t_sql-4.2.1}/tsql/styles.py +0 -0
|
@@ -331,6 +331,61 @@ def test_render_with_style():
|
|
|
331
331
|
assert params == [5]
|
|
332
332
|
|
|
333
333
|
|
|
334
|
+
def test_tsql_render_with_select_query_builder():
|
|
335
|
+
"""Test that tsql.render() works with SelectQueryBuilder"""
|
|
336
|
+
query = Users.select(Users.id, Users.username).where(Users.id > 5)
|
|
337
|
+
|
|
338
|
+
sql, params = tsql.render(query)
|
|
339
|
+
|
|
340
|
+
assert 'SELECT users.id, users.username' in sql
|
|
341
|
+
assert 'WHERE users.id > ?' in sql
|
|
342
|
+
assert params == [5]
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
def test_tsql_render_with_insert_builder():
|
|
346
|
+
"""Test that tsql.render() works with InsertBuilder"""
|
|
347
|
+
query = Users.insert(username='bob', email='bob@example.com')
|
|
348
|
+
|
|
349
|
+
sql, params = tsql.render(query)
|
|
350
|
+
|
|
351
|
+
assert 'INSERT INTO users' in sql
|
|
352
|
+
assert 'username' in sql and 'email' in sql
|
|
353
|
+
assert params == ['bob', 'bob@example.com']
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
def test_tsql_render_with_update_builder():
|
|
357
|
+
"""Test that tsql.render() works with UpdateBuilder"""
|
|
358
|
+
query = Users.update(username='updated').where(Users.id == 5)
|
|
359
|
+
|
|
360
|
+
sql, params = tsql.render(query)
|
|
361
|
+
|
|
362
|
+
assert 'UPDATE users SET' in sql
|
|
363
|
+
assert 'username = ?' in sql
|
|
364
|
+
assert 'WHERE users.id = ?' in sql
|
|
365
|
+
assert params == ['updated', 5]
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
def test_tsql_render_with_delete_builder():
|
|
369
|
+
"""Test that tsql.render() works with DeleteBuilder"""
|
|
370
|
+
query = Users.delete().where(Users.id == 5)
|
|
371
|
+
|
|
372
|
+
sql, params = tsql.render(query)
|
|
373
|
+
|
|
374
|
+
assert 'DELETE FROM users' in sql
|
|
375
|
+
assert 'WHERE users.id = ?' in sql
|
|
376
|
+
assert params == [5]
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
def test_tsql_render_with_query_builder_and_style():
|
|
380
|
+
"""Test that tsql.render() works with query builder and custom style"""
|
|
381
|
+
query = Users.select().where(Users.id == 5)
|
|
382
|
+
|
|
383
|
+
sql, params = tsql.render(query, style=tsql.styles.NUMERIC_DOLLAR)
|
|
384
|
+
|
|
385
|
+
assert '$1' in sql
|
|
386
|
+
assert params == [5]
|
|
387
|
+
|
|
388
|
+
|
|
334
389
|
def test_schema_support():
|
|
335
390
|
"""Test that schema parameter works"""
|
|
336
391
|
class SchemaUsers(Table, table_name='users', schema='public'):
|
|
@@ -258,8 +258,8 @@ def render(query: TSQLQuery, style=None) -> RenderedQuery:
|
|
|
258
258
|
TypeError: If query is a raw string (use t-strings instead)
|
|
259
259
|
"""
|
|
260
260
|
# Handle QueryBuilder (duck typing to avoid circular import)
|
|
261
|
-
if hasattr(query, '
|
|
262
|
-
query = query.
|
|
261
|
+
if hasattr(query, 'to_tsql') and callable(query.to_tsql):
|
|
262
|
+
query = query.to_tsql()
|
|
263
263
|
|
|
264
264
|
if isinstance(query, str):
|
|
265
265
|
raise TypeError(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|