@@ -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