sqlqb 0.2.0__tar.gz → 0.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.
@@ -14,7 +14,8 @@ clean:
14
14
 
15
15
  .PHONY: lint
16
16
  lint:
17
- uv run ruff check .
17
+ uv run ruff check src/ tests/
18
+ uv run ruff format --check src/ tests/
18
19
 
19
20
 
20
21
  .PHONY: test
sqlqb-0.2.1/PKG-INFO ADDED
@@ -0,0 +1,5 @@
1
+ Metadata-Version: 2.5
2
+ Name: sqlqb
3
+ Version: 0.2.1
4
+ Summary: a simple sql query builder
5
+ Requires-Python: >=3.12
@@ -1,16 +1,16 @@
1
1
  [project]
2
2
  name = "sqlqb"
3
- version = "0.2.0"
4
- description = "A simple sql query builder"
3
+ dynamic = ["version"]
4
+ description = "a simple sql query builder"
5
5
  readme = "README.md"
6
6
  authors = []
7
- requires-python = ">=3.12"
7
+ requires-python = ">= 3.12"
8
8
  dependencies = []
9
9
 
10
10
  [dependency-groups]
11
11
  dev = [
12
- "pytest>=9.0.3",
13
12
  "pytest-cov>=7.1.0",
13
+ "pytest>=9.0.3",
14
14
  "ruff>=0.15.17",
15
15
  ]
16
16
  pymysql = [
@@ -31,7 +31,9 @@ source = "vcs"
31
31
  testpaths = ["tests"]
32
32
 
33
33
  [tool.ruff]
34
- line-length = 999
34
+ line-length = 320
35
35
 
36
36
  [tool.ruff.lint]
37
- ignore = ["E501"] # E501 is the line-too-long rule
37
+ ignore = [
38
+ "E501", # E501 is the line-too-long rule
39
+ ]
@@ -1,6 +1,6 @@
1
- from .select import Select
2
- from .insert import Insert
3
1
  from .delete import Delete
2
+ from .insert import Insert
3
+ from .select import Select
4
4
  from .update import Update
5
5
 
6
- __all__ = ["Select", "Insert", "Delete", "Update"]
6
+ __all__ = ["Delete", "Insert", "Select", "Update"]
@@ -14,15 +14,15 @@ class TestDeleteBasic:
14
14
 
15
15
  def test_no_table_raises(self):
16
16
  with pytest.raises(ValueError):
17
- Delete().sql
17
+ _ = Delete().sql
18
18
 
19
19
  def test_empty_table_raises(self):
20
20
  with pytest.raises(ValueError):
21
- Delete().From("").sql
21
+ _ = Delete().From("").sql
22
22
 
23
23
  def test_blank_table_raises(self):
24
24
  with pytest.raises(ValueError):
25
- Delete().From(" ").sql
25
+ _ = Delete().From(" ").sql
26
26
 
27
27
  def test_params_empty_by_default(self):
28
28
  q = Delete().From("users")
@@ -33,23 +33,23 @@ class TestInsertBasic:
33
33
 
34
34
  def test_no_table_raises(self):
35
35
  with pytest.raises(ValueError):
36
- Insert().Values(name="Alice").sql
36
+ _ = Insert().Values(name="Alice").sql
37
37
 
38
38
  def test_no_values_raises(self):
39
39
  with pytest.raises(ValueError):
40
- Insert().Into("users").sql
40
+ _ = Insert().Into("users").sql
41
41
 
42
42
  def test_empty_table_raises(self):
43
43
  with pytest.raises(ValueError):
44
- Insert().Into("")
44
+ _ = Insert().Into("")
45
45
 
46
46
  def test_blank_table_raises(self):
47
47
  with pytest.raises(ValueError):
48
- Insert().Into(" ")
48
+ _ = Insert().Into(" ")
49
49
 
50
50
  def test_empty_values_raises(self):
51
51
  with pytest.raises(ValueError):
52
- Insert().Into("users").Values()
52
+ _ = Insert().Into("users").Values()
53
53
 
54
54
  def test_params_empty_before_values(self):
55
55
  q = Insert().Into("users")
@@ -1,10 +1,11 @@
1
- import pytest
2
1
  from unittest.mock import MagicMock, patch
3
2
 
4
- from sqlqb import pymysql
5
- from sqlqb.pymysql import Select, Insert, Update, Delete, Connection, _to_pymysql
3
+ import pytest
6
4
  from pymysql.cursors import DictCursor
7
5
 
6
+ from sqlqb import pymysql
7
+ from sqlqb.pymysql import Connection, Delete, Insert, Select, Update, _to_pymysql
8
+
8
9
 
9
10
  @pytest.fixture
10
11
  def mock_conn():
@@ -34,19 +34,19 @@ class TestSelectBasic:
34
34
 
35
35
  def test_table_empty_raises(self):
36
36
  with pytest.raises(ValueError):
37
- Select("1").sql
37
+ _ = Select("1").sql
38
38
 
39
39
  def test_columns_empty_raises(self):
40
40
  with pytest.raises(ValueError):
41
- Select().Columns()
41
+ _ = Select().Columns()
42
42
 
43
43
  def test_from_empty_raises(self):
44
44
  with pytest.raises(ValueError):
45
- Select().From("")
45
+ _ = Select().From("")
46
46
 
47
47
  def test_from_blank_raises(self):
48
48
  with pytest.raises(ValueError):
49
- Select().From(" ")
49
+ _ = Select().From(" ")
50
50
 
51
51
  def test_method_chaining_returns_select(self):
52
52
  q = Select()
@@ -96,12 +96,7 @@ class TestJoin:
96
96
  assert q.params == {"status": "active"}
97
97
 
98
98
  def test_join_and_where_params(self):
99
- q = (
100
- Select("u.id")
101
- .From("users u")
102
- .Join("JOIN orders o ON o.user_id = u.id AND o.type = :type", type="sale")
103
- .Where("u.active = :active", active=True)
104
- )
99
+ q = Select("u.id").From("users u").Join("JOIN orders o ON o.user_id = u.id AND o.type = :type", type="sale").Where("u.active = :active", active=True)
105
100
  assert q.params == {"type": "sale", "active": True}
106
101
 
107
102
  def test_no_join_absent(self):
@@ -186,29 +181,13 @@ class TestParams:
186
181
  assert q.params == {}
187
182
 
188
183
  def test_params_accumulate_across_joins_and_wheres(self):
189
- q = (
190
- Select("id")
191
- .From("users")
192
- .Join("JOIN t ON t.id = users.t_id AND t.x = :x", x=42)
193
- .Where("active = :active", active=True)
194
- .Where("role = :role", role="admin")
195
- )
184
+ q = Select("id").From("users").Join("JOIN t ON t.id = users.t_id AND t.x = :x", x=42).Where("active = :active", active=True).Where("role = :role", role="admin")
196
185
  assert q.params == {"x": 42, "active": True, "role": "admin"}
197
186
 
198
187
 
199
188
  class TestClauseOrdering:
200
189
  def test_full_query_clause_order(self):
201
- sql = (
202
- Select("u.id", "u.name")
203
- .From("users u")
204
- .Join("JOIN orders o ON o.user_id = u.id")
205
- .Where("u.active = :active", active=True)
206
- .GroupBy("u.id", "u.name")
207
- .OrderBy("u.name")
208
- .Limit(25)
209
- .Offset(50)
210
- .sql
211
- )
190
+ sql = Select("u.id", "u.name").From("users u").Join("JOIN orders o ON o.user_id = u.id").Where("u.active = :active", active=True).GroupBy("u.id", "u.name").OrderBy("u.name").Limit(25).Offset(50).sql
212
191
  assert sql == "SELECT u.id, u.name FROM users u JOIN orders o ON o.user_id = u.id WHERE u.active = :active GROUP BY u.id, u.name ORDER BY u.name ASC LIMIT 25 OFFSET 50"
213
192
 
214
193
  def test_group_by_before_order_by(self):
@@ -1,6 +1,7 @@
1
1
  import pytest
2
2
  from sqlalchemy import text
3
- from sqlalchemy.engine import Connection as _SAConnection, Engine as _SAEngine
3
+ from sqlalchemy.engine import Connection as _SAConnection
4
+ from sqlalchemy.engine import Engine as _SAEngine
4
5
  from sqlalchemy.pool import StaticPool
5
6
 
6
7
  from sqlqb.sqlalchemy import Connection, Engine, create_engine
@@ -41,8 +41,6 @@ class TestSelect:
41
41
  assert rows == [{"id": 1}, {"id": 2}]
42
42
 
43
43
 
44
-
45
-
46
44
  class TestInsert:
47
45
  def test_insert_returns_rowcount(self, conn):
48
46
  count = conn.Insert().Into("users").Values(id=4, name="Dave", age=40).execute()
@@ -20,19 +20,19 @@ class TestUpdateBasic:
20
20
 
21
21
  def test_empty_table_raises(self):
22
22
  with pytest.raises(ValueError):
23
- Update("")
23
+ _ = Update("")
24
24
 
25
25
  def test_blank_table_raises(self):
26
26
  with pytest.raises(ValueError):
27
- Update(" ")
27
+ _ = Update(" ")
28
28
 
29
29
  def test_no_set_sql_raises(self):
30
30
  with pytest.raises(ValueError):
31
- Update("users").sql
31
+ _ = Update("users").sql
32
32
 
33
33
  def test_empty_set_raises(self):
34
34
  with pytest.raises(ValueError):
35
- Update("users").Set()
35
+ _ = Update("users").Set()
36
36
 
37
37
  def test_params_empty_before_set(self):
38
38
  q = Update("users")