[#2349] fixed view query SELECT DISTINCT parsing
This commit is contained in:
parent
a2a170ad82
commit
cae3315e46
|
@ -1,3 +1,8 @@
|
||||||
|
## (WIP) v0.15.2
|
||||||
|
|
||||||
|
- Fixed view query `SELECT DISTINCT` identifiers parsing ([#2349](https://github.com/pocketbase/pocketbase/discussions/2349#discussioncomment-5706019)).
|
||||||
|
|
||||||
|
|
||||||
## v0.15.1
|
## v0.15.1
|
||||||
|
|
||||||
- Trigger the related `Record` model realtime subscription events on [custom model struct](https://pocketbase.io/docs/custom-models/) save ([#2325](https://github.com/pocketbase/pocketbase/discussions/2325)).
|
- Trigger the related `Record` model realtime subscription events on [custom model struct](https://pocketbase.io/docs/custom-models/) save ([#2325](https://github.com/pocketbase/pocketbase/discussions/2325)).
|
||||||
|
|
|
@ -462,6 +462,8 @@ func (p *identifiersParser) parse(selectQuery string) error {
|
||||||
skip = false
|
skip = false
|
||||||
partType = "select"
|
partType = "select"
|
||||||
activeBuilder = &selectParts
|
activeBuilder = &selectParts
|
||||||
|
case "distinct":
|
||||||
|
continue // ignore as it is not important for the identifiers parsing
|
||||||
case "from":
|
case "from":
|
||||||
skip = false
|
skip = false
|
||||||
partType = "from"
|
partType = "from"
|
||||||
|
@ -477,7 +479,7 @@ func (p *identifiersParser) parse(selectQuery string) error {
|
||||||
partType = "join"
|
partType = "join"
|
||||||
activeBuilder = &joinParts
|
activeBuilder = &joinParts
|
||||||
case "_discard_":
|
case "_discard_":
|
||||||
// do nothing...
|
// skip following tokens
|
||||||
skip = true
|
skip = true
|
||||||
default:
|
default:
|
||||||
isJoin := partType == "join"
|
isJoin := partType == "join"
|
||||||
|
|
|
@ -409,6 +409,20 @@ func TestCreateViewSchema(t *testing.T) {
|
||||||
"custom": schema.FieldTypeJson,
|
"custom": schema.FieldTypeJson,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"query with distinct and reordered id column",
|
||||||
|
`select distinct
|
||||||
|
id as id2,
|
||||||
|
id,
|
||||||
|
123 as custom
|
||||||
|
from demo1
|
||||||
|
`,
|
||||||
|
false,
|
||||||
|
map[string]string{
|
||||||
|
"id2": schema.FieldTypeRelation,
|
||||||
|
"custom": schema.FieldTypeJson,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
|
Loading…
Reference in New Issue