-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Description
When users provide table names or aliases with leading/trailing whitespace (e.g., "User " or "Post p"), the library should automatically trim the whitespace to prevent SQL generation issues.
Current Behavior
Table and alias names are used as-is without trimming, which can lead to:
- Malformed SQL queries
- Unexpected spaces in table aliases
- Type inference issues
Expected Behavior
The library should automatically trim whitespace from:
- Table names in
$from()calls - Table names in join methods (
.join(),.joinUnsafeTypeEnforced(),.joinUnsafeIgnoreType()) - Alias names (both in inline syntax like
"User u"and object syntax)
Examples
// These should all work identically:
prisma.$from("User")
prisma.$from("User ")
prisma.$from(" User")
// Join with trailing space:
prisma.$from("User u")
.join("Post p ", "authorId", "u.id")
// Object syntax with spaces:
prisma.$from("User ")
.join({table: "Post ", src: "authorId", on: "User.id", alias: "p "})Implementation Notes
- Add
Trimtype helper for compile-time trimming - Add runtime
.trim()calls when parsing table/alias strings - Ensure both positional and object syntax support trimming
- Apply to all join methods consistently
Related
This was discovered during the implementation of inline alias syntax (e.g., "User u" instead of separate alias parameter).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request