1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-01-22 13:43:04 +02:00

Merge branch 'master' into develop

This commit is contained in:
Gani Georgiev 2023-04-24 16:04:45 +03:00
commit 7ce21cc4d9
3 changed files with 24 additions and 5 deletions

View File

@ -17,7 +17,9 @@
## (WIP) v0.15.2
- Fixed view query `SELECT DISTINCT` identifiers parsing ([#2349](https://github.com/pocketbase/pocketbase/discussions/2349#discussioncomment-5706019)).
- Fixed View query `SELECT DISTINCT` identifiers parsing ([#2349-5706019](https://github.com/pocketbase/pocketbase/discussions/2349#discussioncomment-5706019)).
- Fixed View collection schema incorrectly resolving multiple aliased fields originating from the same field source ([#2349-5707675](https://github.com/pocketbase/pocketbase/discussions/2349#discussioncomment-5707675)).
## v0.15.1

View File

@ -311,6 +311,7 @@ func (dao *Dao) parseQueryToFields(selectQuery string) (map[string]*queryField,
if field != nil {
clone := *field
clone.Id = "" // unset to prevent duplications if the same field is aliased multiple times
clone.Name = col.alias
result[col.alias] = &queryField{
field: &clone,

View File

@ -395,8 +395,7 @@ func TestCreateViewSchema(t *testing.T) {
created created_alias,
updated updated_alias,
123 as custom
from demo1
`,
from demo1`,
false,
map[string]string{
"id2": schema.FieldTypeRelation,
@ -415,14 +414,31 @@ func TestCreateViewSchema(t *testing.T) {
id as id2,
id,
123 as custom
from demo1
`,
from demo1`,
false,
map[string]string{
"id2": schema.FieldTypeRelation,
"custom": schema.FieldTypeJson,
},
},
{
"query with aliasing the same field multiple times",
`select
a.id as id,
a.text as alias1,
a.text as alias2,
b.text as alias3,
b.text as alias4
from demo1 a
left join demo1 as b`,
false,
map[string]string{
"alias1": schema.FieldTypeText,
"alias2": schema.FieldTypeText,
"alias3": schema.FieldTypeText,
"alias4": schema.FieldTypeText,
},
},
}
for _, s := range scenarios {