Skip to content

Commit 06adc79

Browse files
committed
BUG26840009: Fix generating field names
A field in the projection would be given as [field] AS [alias]. If alias is not provided, we would use the full field name. There should be no other condition. Tests have been added for regression.
1 parent b1e4f35 commit 06adc79

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/mysqlx/expr.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,10 +1165,6 @@ def parse_table_select_projection(self):
11651165
if self.cur_token_type_is(TokenType.AS):
11661166
self.consume_token(TokenType.AS)
11671167
projection["alias"] = self.consume_token(TokenType.IDENT)
1168-
elif get_item_or_attr(projection["source"], "type") is \
1169-
mysqlxpb_enum("Mysqlx.Expr.Expr.Type.IDENT"):
1170-
self.pos -= 1
1171-
projection["alias"] = self.consume_token(TokenType.IDENT)
11721168
else:
11731169
projection["alias"] = fields[len(project_expr)]
11741170
project_expr.append(projection.get_message())

tests/test_mysqlx_crud.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,11 @@ def test_find(self):
11631163
docs = result.fetch_all()
11641164
self.assertTrue("$.age + 100" in docs[0].keys())
11651165

1166+
# tests comma seperated fields
1167+
result = collection.find("$.age = 21").fields("$.age, $.name").execute()
1168+
docs = result.fetch_all()
1169+
self.assertEqual("Fred", docs[0]['$.name'])
1170+
11661171
self.schema.drop_collection(collection_name)
11671172

11681173
def test_modify(self):

0 commit comments

Comments
 (0)