@@ -132,6 +132,9 @@ func (c *cc) convertCreate_virtual_table_stmtContext(n *parser.Create_virtual_ta
132
132
case "fts5" :
133
133
// https://www.sqlite.org/fts5.html
134
134
return c .convertCreate_virtual_table_fts5 (n )
135
+ case "rtree" :
136
+ // https://www.sqlite.org/rtree.html
137
+ return c .convertCreate_virtual_table_rtree (n )
135
138
default :
136
139
return todo (
137
140
fmt .Sprintf ("create_virtual_table. unsupported module name: %q" , moduleName ),
@@ -140,6 +143,38 @@ func (c *cc) convertCreate_virtual_table_stmtContext(n *parser.Create_virtual_ta
140
143
}
141
144
}
142
145
146
+ func (c * cc ) convertCreate_virtual_table_rtree (n * parser.Create_virtual_table_stmtContext ) ast.Node {
147
+ stmt := & ast.CreateTableStmt {
148
+ Name : parseTableName (n ),
149
+ IfNotExists : n .EXISTS_ () != nil ,
150
+ }
151
+
152
+ for i , arg := range n .AllModule_argument () {
153
+ columnExpr , ok := arg .Expr ().(* parser.Expr_qualified_column_nameContext )
154
+ if ! ok {
155
+ continue
156
+ }
157
+
158
+ columnName := columnExpr .Column_name ().GetText ()
159
+
160
+ col := ast.ColumnDef {
161
+ Colname : identifier (columnName ),
162
+ IsNotNull : true ,
163
+ }
164
+
165
+ // first argument in the rtree is an integer (ID)
166
+ // https://www.sqlite.org/rtree.html#column_naming_details
167
+ if i == 0 {
168
+ col .TypeName = & ast.TypeName {Name : "integer" }
169
+ } else {
170
+ col .TypeName = & ast.TypeName {Name : "real" }
171
+ }
172
+
173
+ stmt .Cols = append (stmt .Cols , & col )
174
+ }
175
+ return stmt
176
+ }
177
+
143
178
func (c * cc ) convertCreate_virtual_table_fts5 (n * parser.Create_virtual_table_stmtContext ) ast.Node {
144
179
stmt := & ast.CreateTableStmt {
145
180
Name : parseTableName (n ),
0 commit comments