Bug #92688 Year field in document returns error when used
Description:
A document with a field like Year provides error and cannot be used in filters, fields selection or sort.
The error is with python and js in the Shell.
How to repeat:
Py db.mybooks.find()
[
{
"Authors": [
"David Stokes"
],
"ISBN-13": "9781260135442",
"Language": "en",
"Publisher": "McGraw-Hill Education",
"Title": "MySQL And JSON: A Practical Programming Guide",
"Year": "2018",
"_id": "00005bb732b60000000000000024"
},
{
"Authors": [
"Charles Bell"
],
"ISBN-13": "9781484227244",
"Language": "en",
"Publisher": "Apress",
"Title": "Introducing The MySQL 8 Document Store",
"Year": "2018",
"_id": "00005bb732b60000000000000027"
},
{
"Authors": [
"Jesper Wisborg Krogh"
],
"ISBN-13": "9781484236932",
"Language": "en",
"Publisher": "Apress",
"Title": "MySQL Connector/Python Revealed",
"Year": "2018",
"_id": "00005bb732b60000000000000028"
},
{
"Authors": [
"Charles Bell"
],
"ISBN-13": "9781484238844",
"Language": "en",
"Publisher": "Apress",
"Title": "Introducing InnoDB Cluster",
"Year": "2018",
"_id": "00005bb732b60000000000000029"
},
{
"Authors": [
{
"name": "Jesper Wisborg Krogh"
},
{
"name": "Mikiya Okuno"
}
],
"ISBN-13": "9781484229811",
"Language": "en",
"Title": "Pro MySQL NDB Cluster",
"Year": "2018",
"_id": "00005bb732b6000000000000002d",
"publisher": "Apress"
}
]
Py db.mybooks.find().fields('Title','Year').sort('Year').limit(1)
Traceback (most recent call last):
File "<string>", line 1, in <module>
SystemError: RuntimeError: CollectionFind.fields: Expected token at position 1 but no tokens left.
Suggested fix:
Workaround using backticks:
Py db.mybooks.find().fields('Title','`Year`').sort('`Year`').limit(1)
[
{
"Title": "Understanding MySQL Internals",
"`Year`": "2007"
}
]
1 document in set (0.0006 sec
But it should work without this hack.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.068 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: A document with a field like Year provides error and cannot be used in filters, fields selection or sort. The error is with python and js in the Shell. How to repeat: Py db.mybooks.find() [ { "Authors": [ "David Stokes" ], "ISBN-13": "9781260135442", "Language": "en", "Publisher": "McGraw-Hill Education", "Title": "MySQL And JSON: A Practical Programming Guide", "Year": "2018", "_id": "00005bb732b60000000000000024" }, { "Authors": [ "Charles Bell" ], "ISBN-13": "9781484227244", "Language": "en", "Publisher": "Apress", "Title": "Introducing The MySQL 8 Document Store", "Year": "2018", "_id": "00005bb732b60000000000000027" }, { "Authors": [ "Jesper Wisborg Krogh" ], "ISBN-13": "9781484236932", "Language": "en", "Publisher": "Apress", "Title": "MySQL Connector/Python Revealed", "Year": "2018", "_id": "00005bb732b60000000000000028" }, { "Authors": [ "Charles Bell" ], "ISBN-13": "9781484238844", "Language": "en", "Publisher": "Apress", "Title": "Introducing InnoDB Cluster", "Year": "2018", "_id": "00005bb732b60000000000000029" }, { "Authors": [ { "name": "Jesper Wisborg Krogh" }, { "name": "Mikiya Okuno" } ], "ISBN-13": "9781484229811", "Language": "en", "Title": "Pro MySQL NDB Cluster", "Year": "2018", "_id": "00005bb732b6000000000000002d", "publisher": "Apress" } ] Py db.mybooks.find().fields('Title','Year').sort('Year').limit(1) Traceback (most recent call last): File "<string>", line 1, in <module> SystemError: RuntimeError: CollectionFind.fields: Expected token at position 1 but no tokens left. Suggested fix: Workaround using backticks: Py db.mybooks.find().fields('Title','`Year`').sort('`Year`').limit(1) [ { "Title": "Understanding MySQL Internals", "`Year`": "2007" } ] 1 document in set (0.0006 sec But it should work without this hack.