Skip to content

Allow field name with underscore prefix in Parse.Object.set #2474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
mtrezza opened this issue Mar 2, 2025 · 7 comments · Fixed by #2475
Closed
3 tasks done

Allow field name with underscore prefix in Parse.Object.set #2474

mtrezza opened this issue Mar 2, 2025 · 7 comments · Fixed by #2475
Labels
state:released Released as stable version state:released-alpha Released as alpha version type:feature New feature or improvement of existing feature

Comments

@mtrezza
Copy link
Member

mtrezza commented Mar 2, 2025

New Feature / Enhancement Checklist

Current Limitation

Currently, an error is thrown when setting a field name with underscore prefix in Parse.Object.set. Historically that made sense as these are Parse Server-internal fields. However, with the introduction of access scopes, internal fields can be read from and written to.

Feature / Enhancement Description

The Parse JS SDK should allow sending internal fields to Parse Server, which will then handle the request accordingly. This may not only be relevant for Parse.Object.set but also for Parse.Query conditions on internal fields.

Example Use Case

const obj = new Parse.Object('Test');
obj.set('_internalField', value);

Alternatives / Workarounds

Make a REST API request to avoid the Parse JS SDK restriction.

Copy link

parse-github-assistant bot commented Mar 2, 2025

Thanks for opening this issue!

  • 🎉 We are excited about your ideas for improvement!

@mtrezza mtrezza added the type:feature New feature or improvement of existing feature label Mar 2, 2025
@mtrezza mtrezza changed the title Allow field names with underscore prefix in Parse.Object.set Allow field name with underscore prefix in Parse.Object.set Mar 2, 2025
@mtrezza mtrezza changed the title Allow field name with underscore prefix in Parse.Object.set Allow field name prefixed with underscore in Parse.Object.set Mar 2, 2025
@mtrezza mtrezza changed the title Allow field name prefixed with underscore in Parse.Object.set Allow field name with underscore prefix in Parse.Object.set Mar 2, 2025
@dplewis
Copy link
Member

dplewis commented Mar 2, 2025

I think we should remove the field name check from the SDK. Other SDK's like PHP and iOS don't have this check. They let the server handle it. Using the REST API would make this check useless. Also there isn't a check for class names the server handles that too.

I believe this check was in place because the SDK didn't support dot notation at the time. If dot notation was allowed and not supported the SDK internals would be messed up.

Dot notation is now fully supported. You can view the conversation here on why this check was needed.

@dplewis
Copy link
Member

dplewis commented Mar 3, 2025

Shouldn't this regex allow for underscore already? Looks like the server doesn't support it either. In the case of fields like _context the RESTController overrides it before it gets to the server.

for (const key in attrs) {
if (!/^[A-Za-z][0-9A-Za-z_.]*$/.test(key)) {
return new ParseError(ParseError.INVALID_KEY_NAME, `Invalid key name: "${key}"`);

@dplewis
Copy link
Member

dplewis commented Mar 3, 2025

@mtrezza nvm it doesn't allow underscore at the start

@mtrezza
Copy link
Member Author

mtrezza commented Mar 3, 2025

Yes, the regex requires a letter at the start.

@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 6.1.0-alpha.1

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Mar 5, 2025
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 6.1.0

@parseplatformorg parseplatformorg added the state:released Released as stable version label Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:released Released as stable version state:released-alpha Released as alpha version type:feature New feature or improvement of existing feature
Projects
None yet
3 participants