[#2349] fixed View collection schema incorrectly resolving multiple aliased fields originating from the same field source
This commit is contained in:
		
							parent
							
								
									cae3315e46
								
							
						
					
					
						commit
						e61d48fe7b
					
				|  | @ -1,6 +1,8 @@ | |||
| ## (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 | ||||
|  |  | |||
|  | @ -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, | ||||
|  |  | |||
|  | @ -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 { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue