This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I a running a linq query against a postgres database and the identifiers in the lightspeed generated query are quoted. I did NOT set QuotedIdentifers to true in the config file or in code and verified that the default value is false. Logging from lightspeed shows that all queries have the identifiers quoted. But the following query causes an NpgsqlException exception: Npgsql.NpgsqlException: Generated Query: SELECT linq query: var currentMetersByTerminalIdByMeterDefId = -----> Exception occurs on previous foreach
We are using the LightSpeed nightly build from 9/19. Is there a work around to fix this? Or do we need to update to a different version of LightSpeed? Thanks for your help. Nick |
|
|
Hi Nick, This isnt actually a case of identifier quoting, rather there is an alias involved in the query and alias specifiers need to be quoted because the provider (PostgreSql in this case) needs quoting to distinguish casing. Because you have a mixed case column name you should be using quoting to avoid these types of issues so I would recommend you turn on quoted identifiers to cover this :)
Jeremy |
|
|
I set quoteIdentifiers to true but now it fails on the very first query we execute where before this query worked fine with quoteIdentifiers set to false. SELECT
In my previous post the Lightspeed generated query works if the GamingTerminalId alias and GamingTerminalId identifier are NOT quoted like this: SELECT
Or it works if the alias and identifier are both quoted like this: SELECT
Turning on quoting causes lots of issues but turning it off seems to work well except for the above case. I am not an expert on db case sensitivity, but I know that was is currently being generated does not work. Is this a bug or is there some other configuration I need? Thanks, Nick |
|
|
Hi Nick, Is your table called MeterDefinitions or meterdefinitions? If it is the latter (lower cased form) then you should set the table names accordingly in the designer so that it generates Table attributes for the generated classes with the lower cased name set on them - you will need quoted identifiers on to satisfy the original query as previously mentioned.
Jeremy |
|
|
In the designer the entity attributes are: TableName = MeterDefinitions Name = MeterDefinitionsEntity
We are using migrations to create it and we are currently targeting SqlServer and Postgres databases. After the migration runs the table in the database is lower case meterdefinitions. I assume that is the problem. How do we get the migration to create the table using mixed case? The class the designer generates look like this: [Serializable] ... The Migration that creates the table looks like this: this.AddTable("MeterDefinitions", null, new Field("Id", ModelDataType.Int64, false), new Field[] {
|
|
|
Hi Nick, Thanks for the clarification. We have discussed this internally and while it would be ideal for us to not require the quoting around the grouping specifier as the ideal solution, we would need to add in some more smarts to the querying engine to allow this which isnt something we can do in the short term (but I have added a ticket to our backlog to have a look at this!). For now, the suggested workaround is to have a look at using a custom naming strategy to force the columns into lower case when accessing the database. This will mean you dont have to muck around changing anything in your model. So what you will want to look at doing is to implement a custom naming strategy (have a look at this thread for an example: http://www.mindscape.co.nz/forums/Thread.aspx?PostID=8667) You will want to force lower cased column names like so: public string GetColumnName(string defaultName, string fieldName) { return defaultName.ToLower(); } After that you can also turn quoted identifiers off and you should find the query runs happily as the grouping specifier will be sent quoted in lower case.
Jeremy |
|
|
Thanks Jeremy. That worked.
How do I know if/when the ticket to fix the quoting around the grouping specifier is fixed so I can remove the custom naming stategy?
Nick |
|
|
Hi Nick, We will post an update in this thread with any details of a change. We also aggregate a change log for the week on our blog in the "Weekly Development" posts.
Jeremy |
|