Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ganigeorgiev committed Apr 24, 2023
2 parents 7acd904 + e61d48f commit 7ce21cc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions daos/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
24 changes: 20 additions & 4 deletions daos/view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down

0 comments on commit 7ce21cc

Please sign in to comment.