Skip to content

Commit 407d42c

Browse files
authored
Update build.yaml to support build wheels for python 3.7 and Upgrade to sqlparser-rs 0.56.0 (#271)
* Update build.yaml to support build wheels for python 3.7 According to statistics, Python 3.7's current usage share still exceeds 20%. Since sqloxide itself supports Python 3.7, we hope to ensure support for it when building wheels. * Upgrade to sqlparser-rs 0.56.0 Notes: In v0.55 of sqlparser-rs, the `ObjectName` structure has been changed as shown below. Here is now to migrate. ```diff - pub struct ObjectName(pub Vec<Ident>); + pub struct ObjectName(pub Vec<ObjectNamePart>) ``` Therefore, when using the `parse_sql` function, the data structure of the table name in the return value will change. Previously: ```json { "value": "employee", "quote_style": null, "span": { "start": { "line": 4, "column": 10 }, "end": { "line": 4, "column": 18 } } } ``` Now: ```json { "Identifier": { "value": "employee", "quote_style": null, "span": { "start": { "line": 4, "column": 10 }, "end": { "line": 4, "column": 18 } } } } ```
1 parent 62a83d1 commit 407d42c

File tree

6 files changed

+121
-17
lines changed

6 files changed

+121
-17
lines changed

.github/workflows/build.yaml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,31 @@ jobs:
1919
maturin-version: latest
2020
command: build
2121
manylinux: auto
22-
args: --release --sdist -i 3.8 3.9 3.10 3.11 3.12 3.13
22+
args: --release --sdist -i 3.7 3.8 3.9 3.10 3.11 3.12 3.13
2323
- uses: actions/upload-artifact@v4
2424
with:
2525
name: linux-wheels-${{ matrix.target }}
2626
path: target/wheels/
2727

2828
osx-wheels:
29-
runs-on: macos-latest
29+
runs-on: ${{ matrix.os }}
3030
strategy:
3131
matrix:
32-
python-version: [3.8, 3.9, "3.10", "3.11", "3.12", "3.13"]
32+
include:
33+
- os: macos-13
34+
python-version: 3.7
35+
- os: macos-latest
36+
python-version: 3.8
37+
- os: macos-latest
38+
python-version: 3.9
39+
- os: macos-latest
40+
python-version: "3.10"
41+
- os: macos-latest
42+
python-version: "3.11"
43+
- os: macos-latest
44+
python-version: "3.12"
45+
- os: macos-latest
46+
python-version: "3.13"
3347
steps:
3448
- uses: actions/checkout@v1
3549
- uses: actions-rs/toolchain@v1
@@ -39,7 +53,14 @@ jobs:
3953
- uses: actions/setup-python@v2
4054
with:
4155
python-version: ${{ matrix.python-version }}
42-
- name: Build wheels
56+
- name: Build wheels for Python 3.7
57+
if: matrix.python-version == '3.7'
58+
run: |
59+
rustup target add aarch64-apple-darwin
60+
python3 -m pip install maturin
61+
maturin build --release --target universal2-apple-darwin
62+
- name: Build wheels for other Python versions
63+
if: matrix.python-version != '3.7'
4364
run: |
4465
python3 -m pip install maturin
4566
maturin build --release
@@ -52,7 +73,7 @@ jobs:
5273
runs-on: windows-latest
5374
strategy:
5475
matrix:
55-
python-version: [3.8, 3.9, "3.10", "3.11", "3.12", "3.13"]
76+
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12", "3.13"]
5677
steps:
5778
- uses: actions/checkout@v1
5879
- uses: actions-rs/toolchain@v1
@@ -91,12 +112,14 @@ jobs:
91112
- run: mv ./osx-3.10-wheel/* wheels
92113
- run: mv ./osx-3.9-wheel/* wheels
93114
- run: mv ./osx-3.8-wheel/* wheels
115+
- run: mv ./osx-3.7-wheel/* wheels
94116
- run: mv ./windows-3.13-wheel/* wheels
95117
- run: mv ./windows-3.12-wheel/* wheels
96118
- run: mv ./windows-3.11-wheel/* wheels
97119
- run: mv ./windows-3.10-wheel/* wheels
98120
- run: mv ./windows-3.9-wheel/* wheels
99121
- run: mv ./windows-3.8-wheel/* wheels
122+
- run: mv ./windows-3.7-wheel/* wheels
100123

101124

102125
- name: Publish a Python distribution to PyPI

CHANGELOG.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,63 @@
1+
# 0.1.56
2+
3+
- Upgrade to sqlparser-rs 0.56.0
4+
5+
In v0.55 of sqlparser-rs, the `ObjectName` structure has been changed as shown below. Here is now to migrate.
6+
7+
```diff
8+
- pub struct ObjectName(pub Vec<Ident>);
9+
+ pub struct ObjectName(pub Vec<ObjectNamePart>)
10+
```
11+
12+
Therefore, when using the `parse_sql` function, the data structure of the table name in the return value will change.
13+
14+
Previously:
15+
16+
```json
17+
{
18+
"value": "employee",
19+
"quote_style": null,
20+
"span":
21+
{
22+
"start":
23+
{
24+
"line": 4,
25+
"column": 10
26+
},
27+
"end":
28+
{
29+
"line": 4,
30+
"column": 18
31+
}
32+
}
33+
}
34+
```
35+
36+
Now:
37+
38+
39+
```json
40+
{
41+
"Identifier":
42+
{
43+
"value": "employee",
44+
"quote_style": null,
45+
"span":
46+
{
47+
"start":
48+
{
49+
"line": 4,
50+
"column": 10
51+
},
52+
"end":
53+
{
54+
"line": 4,
55+
"column": 18
56+
}
57+
}
58+
}
59+
}
60+
```
161

262
# 0.1.36
363

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sqloxide"
3-
version = "0.1.54"
3+
version = "0.1.56"
44
authors = ["Will Eaton <me@wseaton.com>"]
55
edition = "2021"
66

@@ -17,5 +17,5 @@ version = "0.22"
1717
features = ["extension-module"]
1818

1919
[dependencies.sqlparser]
20-
version = "0.54.0"
20+
version = "0.56.0"
2121
features = ["serde", "visitor"]

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "sqloxide"
3-
version = "0.1.54rc2"
3+
version = "0.1.56"
44
authors = [{ name = "Will Eaton", email= "<me@wseaton.com>" }]
55
repository = "https://github.com/wseaton/sqloxide"
66
license = "MIT"

src/visitor.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use pyo3::prelude::*;
66
use serde::Serialize;
77

88
use sqlparser::ast::{
9-
Statement, {visit_expressions, visit_expressions_mut, visit_relations, visit_relations_mut},
9+
Statement, ObjectNamePart, {visit_expressions, visit_expressions_mut, visit_relations, visit_relations_mut},
1010
};
1111

1212
// Refactored function for handling depythonization
@@ -61,7 +61,8 @@ pub fn mutate_relations(_py: Python, parsed_query: &Bound<'_, PyAny>, func: &Bou
6161
for statement in &mut statements {
6262
visit_relations_mut(statement, |table| {
6363
for section in &mut table.0 {
64-
let val = match func.call1((section.value.clone(),)) {
64+
let ObjectNamePart::Identifier(ident) = section;
65+
let val = match func.call1((ident.value.clone(),)) {
6566
Ok(val) => val,
6667
Err(e) => {
6768
let msg = e.to_string();
@@ -71,7 +72,7 @@ pub fn mutate_relations(_py: Python, parsed_query: &Bound<'_, PyAny>, func: &Bou
7172
}
7273
};
7374

74-
section.value = val.to_string();
75+
ident.value = val.to_string();
7576
}
7677
ControlFlow::Continue(())
7778
});

tests/test_sqloxide.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,14 @@ def test_extract_relations():
4343
ast = parse_sql(sql=SQL, dialect="ansi")
4444

4545
assert extract_relations(parsed_query=ast)[0][0] == {
46-
"value": "employee",
47-
"quote_style": None,
46+
"Identifier": {
47+
"value": "employee",
48+
"quote_style": None,
49+
"span": {
50+
"start": {"line": 4, "column": 10},
51+
"end": {"line": 4, "column": 18},
52+
},
53+
}
4854
}
4955

5056

@@ -54,7 +60,7 @@ def func(x):
5460

5561
ast = parse_sql(sql=SQL, dialect="ansi")
5662
assert mutate_relations(parsed_query=ast, func=func) == [
57-
'SELECT employee.first_name, employee.last_name, c.start_time, c.end_time, call_outcome.outcome_text FROM employee JOIN "call2"."call2"."call2" AS c ON c.employee_id = employee.id JOIN call2_outcome ON c.call_outcome_id = call_outcome.id ORDER BY c.start_time ASC'
63+
'SELECT employee.first_name, employee.last_name, c.start_time, c.end_time, call_outcome.outcome_text FROM employee INNER JOIN "call2"."call2"."call2" AS c ON c.employee_id = employee.id INNER JOIN call2_outcome ON c.call_outcome_id = call_outcome.id ORDER BY c.start_time ASC'
5864
]
5965

6066

@@ -81,7 +87,7 @@ def func(x):
8187
ast = parse_sql(sql=SQL, dialect="ansi")
8288
result = mutate_expressions(parsed_query=ast, func=func)
8389
assert result == [
84-
'SELECT EMPLOYEE.FIRST_NAME, EMPLOYEE.LAST_NAME, C.START_TIME, C.END_TIME, CALL_OUTCOME.OUTCOME_TEXT FROM employee JOIN "call"."call"."call" AS c ON C.EMPLOYEE_ID = EMPLOYEE.ID JOIN call_outcome ON C.CALL_OUTCOME_ID = CALL_OUTCOME.ID ORDER BY C.START_TIME ASC'
90+
'SELECT EMPLOYEE.FIRST_NAME, EMPLOYEE.LAST_NAME, C.START_TIME, C.END_TIME, CALL_OUTCOME.OUTCOME_TEXT FROM employee INNER JOIN "call"."call"."call" AS c ON C.EMPLOYEE_ID = EMPLOYEE.ID INNER JOIN call_outcome ON C.CALL_OUTCOME_ID = CALL_OUTCOME.ID ORDER BY C.START_TIME ASC'
8591
]
8692

8793

@@ -93,7 +99,21 @@ def test_extract_expressions():
9399

94100
assert exprs[0] == {
95101
"CompoundIdentifier": [
96-
{"value": "employee", "quote_style": None},
97-
{"value": "first_name", "quote_style": None},
102+
{
103+
"value": "employee",
104+
"quote_style": None,
105+
"span": {
106+
"end": {"column": 20, "line": 2},
107+
"start": {"column": 12, "line": 2},
108+
},
109+
},
110+
{
111+
"value": "first_name",
112+
"quote_style": None,
113+
"span": {
114+
"end": {"column": 31, "line": 2},
115+
"start": {"column": 21, "line": 2},
116+
},
117+
},
98118
]
99119
}

0 commit comments

Comments
 (0)