You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Parse Server currently prohibits that field name strings start with a number or contain only numbers.
There seems to be no technical reason for this limitation:
JavaScript object allows any string as key
MongoDB allows any string as key as long as it doesn't interfere with reserves symbols, such as $ or operators such as . in dot notation. Going back as far as MongoDB 2.4 (2016) the restrictions are still the same today:
Field names cannot contain null characters, dots (.) or dollar signs ($).
Parse Server allows - according to docs - any alphanumeric string as key. There seems to be no documented limitation that field names cannot be a string that begins with or only contains numbers.
The validation has been added in Parse Server 2.0.8, which was one of the WIP releases to open source parse server, so it has been there "from the beginning", but it is unclear today why:
After looking deeper into this, I assume that the restriction is based on historic (non-MongoDB DBMS) restrictions, where SQL parsers are optimized to expect identifiers with a leading latin letter and the QL would for example require quoting to differentiate identifiers from numeric values when omitting quotation:
For example in PostgreSQL:
SELECT 123abc is interpreted as SELECT 123 AS abc.
The SQL docs describe the complexity of quotation requirements:
Identifiers may begin with a digit but unless quoted may not consist solely of digits.
From that I assume that this limitation may not be necessary for the typical Parse Server architecture using MongoDB. However, it may be reflected in how the Parse Server PostgreSQL DB adapter parses and constructs queries and possibly for other non-public or experimental Parse Server DB adapters. Due to this complexity and for compatibility reasons, I suggest to keep this limitation in place and close this issue.
New Issue Checklist
Issue Description
Parse Server currently prohibits that field name strings start with a number or contain only numbers.
There seems to be no technical reason for this limitation:
The validation has been added in Parse Server 2.0.8, which was one of the WIP releases to open source parse server, so it has been there "from the beginning", but it is unclear today why:
d934f3a#diff-b8769df8db7b0a496c0f6bb5478693ae3b54bd5c0e6db957e3b47de558646777R68-R70
Steps to reproduce
Add field name (or class name) with leading number, e.g. "1field".
Actual Outcome
Adding the field fails validation.
Expected Outcome
Adding the field should pass validation.
Failing Test Case / Pull Request
(none)
Environment
Server
4.5.0
irrelevant
irrelevant
Database
irrelevant
irrelevant
irrelevant
Client
irrelevant
irrelevant
Logs
(none)
The text was updated successfully, but these errors were encountered: