Skip to content

Commit e224e84

Browse files
committed
Fixes
1 parent 5c683ff commit e224e84

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

database/database.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ func (db *Database) activate(ctx context.Context) (err error) {
4747
config.ConnConfig.Tracer = dbe.dbtracer
4848

4949
config.AfterConnect = func(ctx context.Context, conn *pgx.Conn) error {
50+
// Force text format for tsvector — pgx v5.9+ defaults to binary,
51+
// but we decode RawValues() as text.
52+
conn.TypeMap().RegisterType(&pgtype.Type{
53+
Name: "tsvector",
54+
OID: pgtype.TSVectorOID,
55+
Codec: &pgtype.TextFormatOnlyCodec{Codec: pgtype.TSVectorCodec{}},
56+
})
5057
var set string
5158
var err error
5259
if len(dbe.config.SchemaSearchPath) != 0 {

database/querybuilder.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,13 +1010,14 @@ func buildRecursiveSelect(table, schema string, parts *QueryParts, options *Quer
10101010
if rec.ViaTable == "" {
10111011
// --- Single-table mode ---
10121012

1013-
// Base case
1013+
// Base case — when ExcludeStart is true (after operator), skip mainWhere on the
1014+
// seed row so it remains a traversal anchor even if it doesn't match the filter.
10141015
q.WriteString("SELECT " + qtable + ".*, 0 AS __depth, ARRAY[" + qtable + "." + startField + "] AS __path")
10151016
q.WriteString(" FROM " + qtable)
10161017
nmarker++
10171018
q.WriteString(" WHERE " + qtable + "." + startField + " = $" + strconv.Itoa(nmarker))
10181019
valueList = append(valueList, rec.StartValue)
1019-
if mainWhere != "" {
1020+
if mainWhere != "" && !rec.ExcludeStart {
10201021
q.WriteString(" AND " + mainWhere)
10211022
}
10221023

@@ -1042,13 +1043,14 @@ func buildRecursiveSelect(table, schema string, parts *QueryParts, options *Quer
10421043
viaFrom := quote(rec.ViaFromCol)
10431044
viaTo := quote(rec.ViaToCol)
10441045

1045-
// Base case: the start node itself
1046+
// Base case: the start node itself — when ExcludeStart is true (after operator),
1047+
// skip mainWhere so the seed remains a traversal anchor.
10461048
q.WriteString("SELECT " + qtable + ".*, 0 AS __depth, ARRAY[" + qtable + "." + startField + "] AS __path")
10471049
q.WriteString(" FROM " + qtable)
10481050
nmarker++
10491051
q.WriteString(" WHERE " + qtable + "." + startField + " = $" + strconv.Itoa(nmarker))
10501052
valueList = append(valueList, rec.StartValue)
1051-
if mainWhere != "" {
1053+
if mainWhere != "" && !rec.ExcludeStart {
10521054
q.WriteString(" AND " + mainWhere)
10531055
}
10541056

0 commit comments

Comments
 (0)