user2012677
user2012677

Reputation: 5745

Rails 5 and Postgres - Can I use a "?" in the field name?

I am wondering if using a "?" in a field name will cause any problems when using Rails 5 and Postgres?

Example of field name:

want_to_sell?

has_certification?

Upvotes: 0

Views: 33

Answers (1)

user330315
user330315

Reputation:

In SQL, a question mark ? is invalid in an identifier. The only way you could use that is if you use the dreaded quoted identifiers.

create table bad_names
(
  "want_to_sell?"      boolean,
  "has_certification?" boolean
);

But I strongly suggest you do not do that.

Quoted identifiers generate so many problems down the line that they are not worth the perceived little advantage of following the naming conventions from a different programming language.

Upvotes: 2

Related Questions