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.
Files changed (31) hide show
  1. {t_sql-4.2.0 → t_sql-4.2.1}/PKG-INFO +1 -1
  2. {t_sql-4.2.0 → t_sql-4.2.1}/pyproject.toml +1 -1
  3. {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_query_builder.py +55 -0
  4. {t_sql-4.2.0 → t_sql-4.2.1}/tsql/__init__.py +2 -2
  5. {t_sql-4.2.0 → t_sql-4.2.1}/.dockerignore +0 -0
  6. {t_sql-4.2.0 → t_sql-4.2.1}/.github/workflows/publish.yml +0 -0
  7. {t_sql-4.2.0 → t_sql-4.2.1}/.github/workflows/test.yml +0 -0
  8. {t_sql-4.2.0 → t_sql-4.2.1}/.gitignore +0 -0
  9. {t_sql-4.2.0 → t_sql-4.2.1}/Dockerfile +0 -0
  10. {t_sql-4.2.0 → t_sql-4.2.1}/LICENSE +0 -0
  11. {t_sql-4.2.0 → t_sql-4.2.1}/README.md +0 -0
  12. {t_sql-4.2.0 → t_sql-4.2.1}/compose.yaml +0 -0
  13. {t_sql-4.2.0 → t_sql-4.2.1}/context7.json +0 -0
  14. {t_sql-4.2.0 → t_sql-4.2.1}/pytest.ini +0 -0
  15. {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_alembic_integration.py +0 -0
  16. {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_asyncpg_integration.py +0 -0
  17. {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_different_object_types.py +0 -0
  18. {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_escaped.py +0 -0
  19. {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_escaped_binary_hex.py +0 -0
  20. {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_helper_functions.py +0 -0
  21. {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_injection_edge_cases.py +0 -0
  22. {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_injection_protection_validation.py +0 -0
  23. {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_injections_for_escaped.py +0 -0
  24. {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_mysql_integration.py +0 -0
  25. {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_parameter_names.py +0 -0
  26. {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_sqlalchemy_integration.py +0 -0
  27. {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_sqlite_integration.py +0 -0
  28. {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_styles.py +0 -0
  29. {t_sql-4.2.0 → t_sql-4.2.1}/tests/test_tsql.py +0 -0
  30. {t_sql-4.2.0 → t_sql-4.2.1}/tsql/query_builder.py +0 -0
  31. {t_sql-4.2.0 → t_sql-4.2.1}/tsql/styles.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: t-sql
3
- Version: 4.2.0
3
+ Version: 4.2.1
4
4
  Summary: Safe SQL. SQL queries for python t-strings (PEP 750)
5
5
  Project-URL: Homepage, https://github.com/nhumrich/t-sql
6
6
  License-File: LICENSE
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "t-sql"
7
- version = "4.2.0"
7
+ version = "4.2.1"
8
8
  description = "Safe SQL. SQL queries for python t-strings (PEP 750)"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.14"
@@ -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, 'build') and callable(query.build):
262
- query = query.build()
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