Skip to content

Commit fa5ccd8

Browse files
authored
Updating view handling code; updating sqlalchemy version (#89)
* Updating view handling code; pinning sqlalchemy version * changing version pinning to be more flexible * adding scheduled test for checking dependencies
1 parent cc26b7c commit fa5ccd8

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This workflow will install the package on a regular schedule to check if there are any depenedency issues.
2+
3+
name: Test Astrodbkit Dependencies
4+
5+
on:
6+
schedule:
7+
- cron: '0 16 * * *'
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: [3.11, 3.12, 3.13]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
# install package and requirements
27+
pip install ".[all]"
28+
- name: Test with pytest
29+
run: |
30+
pytest

astrodbkit/views.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,24 @@ def view_doesnt_exist(ddl, target, connection, **kw):
4545

4646

4747
def view(name, metadata, selectable):
48-
t = table(name)
4948

50-
t._columns._populate_separate_keys(col._make_proxy(t) for col in selectable.selected_columns)
49+
t = sa.table(
50+
name,
51+
*(
52+
sa.Column(c.name, c.type, primary_key=c.primary_key)
53+
for c in selectable.selected_columns
54+
),
55+
)
56+
t.primary_key.update(c for c in t.c if c.primary_key)
5157

5258
sa.event.listen(
5359
metadata,
5460
"after_create",
5561
CreateView(name, selectable).execute_if(callable_=view_doesnt_exist),
5662
)
57-
sa.event.listen(metadata, "before_drop", DropView(name).execute_if(callable_=view_exists))
63+
sa.event.listen(
64+
metadata,
65+
"before_drop",
66+
DropView(name).execute_if(callable_=view_exists),
67+
)
5868
return t

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ requires-python = ">= 3.11"
2222
dependencies = [
2323
"astropy",
2424
"astroquery",
25-
"sqlalchemy>=2.0",
25+
"sqlalchemy>=2.0.38",
2626
"pandas>=1.0.4",
2727
"packaging",
2828
"specutils>=1.0",

0 commit comments

Comments
 (0)