Fixed linting issues
Some checks failed
CI / Test (1.24) (push) Successful in -25m42s
CI / Test (1.25) (push) Successful in -25m40s
CI / Build (push) Successful in -25m54s
CI / Lint (push) Successful in -25m27s
Integration Tests / Integration Tests (push) Failing after -25m48s

This commit is contained in:
2025-12-28 14:51:19 +02:00
parent 2a271b9859
commit b55737ab4c
2 changed files with 9 additions and 13 deletions

View File

@@ -35,10 +35,10 @@ jobs:
run: |
docker run -d \
--name relspec-test-postgres \
--network host \
-e POSTGRES_USER=relspec \
-e POSTGRES_PASSWORD=relspec_test_password \
-e POSTGRES_DB=relspec_test \
-p 5432:5432 \
postgres:16-alpine
- name: Wait for PostgreSQL to be ready
@@ -54,23 +54,18 @@ jobs:
done
sleep 2
- name: Install PostgreSQL client
- name: Copy init script into container
run: |
sudo apt-get update
sudo apt-get install -y postgresql-client
docker cp tests/postgres/init.sql relspec-test-postgres:/tmp/init.sql
- name: Initialize test database
env:
PGPASSWORD: relspec_test_password
run: |
psql -h localhost -U relspec -d relspec_test -f tests/postgres/init.sql
docker exec relspec-test-postgres psql -U relspec -d relspec_test -f /tmp/init.sql
- name: Verify database setup
env:
PGPASSWORD: relspec_test_password
run: |
echo "Verifying database initialization..."
psql -h localhost -U relspec -d relspec_test -c "
docker exec relspec-test-postgres psql -U relspec -d relspec_test -c "
SELECT
(SELECT COUNT(*) FROM pg_namespace WHERE nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast') AND nspname NOT LIKE 'pg_%') as schemas,
(SELECT COUNT(*) FROM pg_tables WHERE schemaname NOT IN ('pg_catalog', 'information_schema')) as tables,

View File

@@ -438,21 +438,22 @@ func (r *Reader) parseRelationshipConstraints(table *models.Table, structType *a
var fkTable *models.Table
var fkColumn, refTable, refColumn string
if relType == "belongs-to" {
switch strings.ToLower(relType) {
case "belongs-to":
// For belongs-to: FK is on the current table
// join:user_id=id means table.user_id references referencedTable.id
fkTable = table
fkColumn = joinInfo.ForeignKey
refTable = referencedTable.Name
refColumn = joinInfo.ReferencedKey
} else if relType == "has-many" {
case "has-many":
// For has-many: FK is on the referenced table
// join:id=user_id means referencedTable.user_id references table.id
fkTable = referencedTable
fkColumn = joinInfo.ReferencedKey
refTable = table.Name
refColumn = joinInfo.ForeignKey
} else {
default:
continue
}