Skip to content

Commit 887f38c

Browse files
committed
Exclude partial unique indexes in *PostgresDriver.loadUniqueColumns
1 parent 3dcc359 commit 887f38c

File tree

1 file changed

+8
-5
lines changed
  • drivers/sqlboiler-psql/driver

1 file changed

+8
-5
lines changed

drivers/sqlboiler-psql/driver/psql.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import (
1515

1616
"github.com/aarondl/sqlboiler/v4/importers"
1717

18-
"github.com/friendsofgo/errors"
1918
"github.com/aarondl/strmangle"
19+
"github.com/friendsofgo/errors"
2020

2121
"github.com/aarondl/sqlboiler/v4/drivers"
2222

@@ -365,7 +365,7 @@ method_b as (
365365
inner join pg_class pgc on pgix.indexname = pgc.relname and pgc.relkind = 'i' and pgc.relnatts = 1
366366
inner join pg_index pgi on pgi.indexrelid = pgc.oid
367367
inner join pg_attribute pga on pga.attrelid = pgi.indrelid and pga.attnum = ANY(pgi.indkey)
368-
where pgi.indisunique = true
368+
where pgi.indisunique = true and pgi.indpred is null
369369
),
370370
results as (
371371
select * from method_a
@@ -390,7 +390,10 @@ select * from results;
390390
return nil
391391
}
392392

393-
func (p *PostgresDriver) ViewColumns(schema, tableName string, whitelist, blacklist []string) ([]drivers.Column, error) {
393+
func (p *PostgresDriver) ViewColumns(schema, tableName string, whitelist, blacklist []string) (
394+
[]drivers.Column,
395+
error,
396+
) {
394397
return p.Columns(schema, tableName, whitelist, blacklist)
395398
}
396399

@@ -601,7 +604,7 @@ func (p *PostgresDriver) Columns(schema, tableName string, whitelist, blacklist
601604
}
602605
}
603606
}
604-
607+
605608
if len(blacklist) > 0 {
606609
cols := drivers.ColumnsFromList(blacklist, tableName)
607610
if len(cols) > 0 {
@@ -1157,4 +1160,4 @@ func (p *PostgresDriver) getVersion() (int, error) {
11571160
}
11581161

11591162
return versionInfo.ServerVersionNum, nil
1160-
}
1163+
}

0 commit comments

Comments
 (0)