Skip to content

Commit c3f69df

Browse files
authored
gen: Add support for the ltree extension (#385)
1 parent 755203b commit c3f69df

File tree

5 files changed

+71
-0
lines changed

5 files changed

+71
-0
lines changed

internal/dinosql/gen.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,17 @@ func (r Result) goInnerType(col core.Column, settings config.CombinedSettings) s
738738
case "macaddr", "macaddr8":
739739
return "net.HardwareAddr"
740740

741+
case "ltree", "lquery", "ltxtquery":
742+
// This module implements a data type ltree for representing labels
743+
// of data stored in a hierarchical tree-like structure. Extensive
744+
// facilities for searching through label trees are provided.
745+
//
746+
// https://www.postgresql.org/docs/current/ltree.html
747+
if notNull {
748+
return "string"
749+
}
750+
return "sql.NullString"
751+
741752
case "void":
742753
// A void value always returns NULL. Since there is no built-in NULL
743754
// value into the SQL package, we'll use sql.NullBool

internal/endtoend/testdata/ext_ltree/go/db.go

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/ext_ltree/go/models.go

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CREATE EXTENSION IF NOT EXISTS ltree;
2+
3+
CREATE TABLE foo (
4+
qualified_name ltree,
5+
name_query lquery,
6+
fts_name_query ltxtquery
7+
);
8+
9+
SELECT * FROM foo;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"version": "1",
3+
"packages": [{
4+
"path": "go",
5+
"name": "querytest",
6+
"schema": "query.sql",
7+
"queries": "query.sql"
8+
}]
9+
}

0 commit comments

Comments
 (0)