Skip to content

Commit 712a307

Browse files
author
m.kindritskiy
committed
Run db integration tests on CI
1 parent 93d7555 commit 712a307

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

.github/workflows/test.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ jobs:
3636
- name: Run unit tests
3737
run: tox run -- --cov-report=term
3838

39+
test-db:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v3
43+
- name: Install Lets
44+
uses: lets-cli/lets-action@v1.1
45+
with:
46+
version: latest
47+
- name: Test database integration
48+
run: timeout 600 lets test-pg
49+
3950
federation-test:
4051
runs-on: ubuntu-latest
4152
steps:

hiku/sources/aiopg.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,14 @@ def in_impl(
3737
def select_expr(
3838
self, fields_: List[Field], ids: Iterable
3939
) -> Tuple[Select, Callable]:
40-
visited = set()
41-
columns = []
42-
query_columns = []
43-
for f in fields_:
44-
column = self.from_clause.c[f.name]
45-
columns.append(column)
46-
47-
if f.name not in visited and column != self.primary_key:
48-
visited.add(f.name)
49-
query_columns.append(column)
40+
result_columns = [self.from_clause.c[f.name] for f in fields_]
41+
# aiopg requires unique columns to be passed to select,
42+
# otherwise it will raise an error
43+
query_columns = [
44+
column
45+
for f in _uniq_fields(fields_)
46+
if (column := self.from_clause.c[f.name]) != self.primary_key
47+
]
5048

5149
expr = (
5250
sqlalchemy.select(
@@ -58,7 +56,7 @@ def select_expr(
5856

5957
def result_proc(rows: List[_sa.Row]) -> List:
6058
rows_map = {
61-
row[self.primary_key]: [row[c] for c in columns]
59+
row[self.primary_key]: [row[c] for c in result_columns]
6260
for row in map(_sa._process_result_row, rows)
6361
}
6462

lets.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ commands:
5757
test-pg:
5858
description: Run tests with pg
5959
depends: [_build-tests]
60-
cmd: [docker-compose, run, --rm, test-pg]
60+
cmd: [docker compose, run, --rm, test-pg]
6161

6262
test-tox:
6363
description: Run tests using tox

0 commit comments

Comments
 (0)