I work on a team that is using ActiveRecord to access the schema on a MSSQL server. Modifying the schema is not an option and the column names have spaces in them, a la SPACEY COLUMN
.
When writing the ActiveRecord class to access a table with spaces in it, what is good practice?
We also need this to work with factory girl...
AR-JDBC (as well as the AR-SQLServer-Adapter) will/should handle this just fine since it auto-magically quotes column name identifiers using "[ COlumn NAME ]" ... I personally would hide this from bubbling up as much as possible e.g. using aliases :
Consider
User
is the Model andUser Name
is the column you need to access.You can add multiple conditions also,
You can also try,
And if your table itself has space in it. Try,