Skip to content
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

Optional double quotes for case insensitive columns? #248

Closed
renato opened this issue Oct 9, 2017 · 4 comments
Closed

Optional double quotes for case insensitive columns? #248

renato opened this issue Oct 9, 2017 · 4 comments
Assignees
Labels

Comments

@renato
Copy link

renato commented Oct 9, 2017

I have a GraphQL object Activity with a field named "plannedDate", but I personally prefer my database to be case insensitive, so my PostgreSQL field is planneddate, without double quotes.

The problem is, if I use Join Monster with the "plannedDate" GraphQL field, it assumes it's the same case-sensitive name in the database, which it isn't in my case.

I'm currently stripping double quotes but only for these fields (the "'s from the aliases must be kept), but is it possible to achieve the same thing without removing the quotes?

Thanks.

@leonardfactory
Copy link

Have you tried with sqlColumn metadata? (sqlColumn: "planneddate")

From the docs:

  email: {
      type: GraphQLString,
      // if the column name is different, it must be specified specified
      sqlColumn: 'email_address'
    },

@renato
Copy link
Author

renato commented Oct 25, 2017

Yes, this would be a solution, but it would be easier to just ignore the double quotes for the identifiers instead of setting sqlColumn for every camelCase field.

Knex supports a "wrapIdentifier", which can be used to do it or convert camelCase to snake_case, for example. knex/knex#2084

Anyway, I'm using the camelCase convention in the database too for now.

@renato
Copy link
Author

renato commented Dec 7, 2017

I'm currently auto-generating the join-monster sqlColumn information for all the fields using the keys in schema._typeMap.TypeName._fields, converting to whatever I need.

This approach in addition to using wrapIdentifier allows me to use a camelCase -> snake_case or camelCase -> lowercase correctly.

It would be great to drop this custom code and use something standard from join-monster.

@nicoabie nicoabie self-assigned this May 26, 2024
@nicoabie
Copy link
Contributor

JM supports a way of overriding the column name. I think adding more on JM's part is making the API unnecessarily complex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants