Skip to content

fmodata: quote reserved field name ID in OData select/filter when not using entity IDs #216

@eluce2

Description

@eluce2

Summary

@proofkit/fmodata quotes lowercase id, but not uppercase ID.

Against FileMaker OData, FILES?$select=ID fails with:

{"error":{"code":"-1002","message":"Error: parse failure in URL at: 'ID'"}}

But FILES?$select=%22ID%22 works.

Repro

Schema field name is literally ID.

await db
  .from(FILES)
  .list()
  .where(eq(FILES.s3key, someKey))
  .select({ ID: FILES.ID })
  .top(1)
  .execute({ useEntityIds: false });

Generated query string:

/FILES?$filter=s3key eq '...jpg'&$top=1&$select=ID

Live FM response:

{"error":{"code":"-1002","message":"Error: parse failure in URL at: 'ID'"}}

Quoted version works:

/FILES?$top=1&$select=%22ID%22

Response:

{"@context":"...#FILES(\"ID\")","value":[]}

Likely cause

needsFieldQuoting() only special-cases lowercase id:

  • packages/fmodata/src/client/builders/select-utils.ts
  • comment says quote "id" as reserved word

That same helper is also used in filters via:

  • packages/fmodata/src/orm/operators.ts

Expected

Treat ID case-insensitively, at least for reserved-word quoting.

Likely fix:

  • change fieldName === "id" to fieldName.toLowerCase() === "id"

Workaround

Use entity IDs, or avoid explicit $select=ID on FileMaker layouts with a field named ID.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions