Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 2, 2026

Thanks for assigning this issue to me. I'm starting to work on it and will keep this PR's description up to date as I form a plan and make progress.

Original prompt

This section details on the original issue you should resolve

<issue_title>Parse failures of COLLATE:</issue_title>
<issue_description>We can use COLLATE to change collating sequence for a single expression:

The COLLATE operator is a unary postfix operator that assigns a collating sequence to an expression. The collating sequence set by the COLLATE operator overrides the collating sequence determined by the COLLATE clause in a table column definition. See the detailed discussion on collating sequences in the Datatype In SQLite3 document for additional information.

https://www.sqlite.org/lang_expr.html

Image
sqlite> SELECT * FROM vals;
+---+
| A |
+---+
| a |
| b |
| c |
| d |
| e |
+---+
sqlite> SELECT * FROM vals WHERE a < 'C' ;
sqlite> SELECT * FROM vals WHERE a < 'C' COLLATE NOCASE;
+---+
| A |
+---+
| a |
| b |
+---+

However, such queries produce the following parse error: https://go.dev/play/p/q1rykRy4OZ7

package main

import (
	"fmt"
	"strings"

	"github.com/rqlite/sql"
)

func main() {
	for _, q := range []string{
		`SELECT * FROM vals WHERE a < 'C' COLLATE NOCASE`,
	} {
		p := sql.NewParser(strings.NewReader(q))
		s, err := p.ParseStatement()
		fmt.Printf("%q\n   err: %v\n  stmt: %#v\n", q, err, s)
	}
}

produces:

"SELECT * FROM vals WHERE a < 'C' COLLATE NOCASE"
   err: 1:34: expected semicolon or EOF, found 'COLLATE'
  stmt: &sql.SelectStatement{WithClause:(*sql.WithClause)(nil), Values:sql.Pos{Offset:0, Line:0, Column:0}, ValueLists:[]*sql.ExprList(nil), Select:sql.Pos{Offset:0, Line:1, Column:1}, Distinct:sql.Pos{Offset:0, Line:0, Column:0}, All:sql.Pos{Offset:0, Line:0, Column:0}, Columns:[]*sql.ResultColumn{(*sql.ResultColumn)(0xc000146000)}, From:sql.Pos{Offset:9, Line:1, Column:10}, Source:(*sql.QualifiedTableName)(0xc000148000), Where:sql.Pos{Offset:19, Line:1, Column:20}, WhereExpr:(*sql.BinaryExpr)(0xc000104080), Group:sql.Pos{Offset:0, Line:0, Column:0}, GroupBy:sql.Pos{Offset:0, Line:0, Column:0}, GroupByExprs:[]sql.Expr(nil), Having:sql.Pos{Offset:0, Line:0, Column:0}, HavingExpr:sql.Expr(nil), Window:sql.Pos{Offset:0, Line:0, Column:0}, Windows:[]*sql.Window(nil), Union:sql.Pos{Offset:0, Line:0, Column:0}, UnionAll:sql.Pos{Offset:0, Line:0, Column:0}, Intersect:sql.Pos{Offset:0, Line:0, Column:0}, Except:sql.Pos{Offset:0, Line:0, Column:0}, Compound:(*sql.SelectStatement)(nil), Order:sql.Pos{Offset:0, Line:0, Column:0}, OrderBy:sql.Pos{Offset:0, Line:0, Column:0}, OrderingTerms:[]*sql.OrderingTerm(nil), Limit:sql.Pos{Offset:0, Line:0, Column:0}, LimitExpr:sql.Expr(nil), Offset:sql.Pos{Offset:0, Line:0, Column:0}, OffsetComma:sql.Pos{Offset:0, Line:0, Column:0}, OffsetExpr:sql.Expr(nil)}
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI requested a review from otoolep February 2, 2026 20:16
@otoolep otoolep marked this pull request as ready for review February 3, 2026 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parse failures of COLLATE:

2 participants