| Issue 55: | Bug: Escaped column names | |
| 1 person starred this issue and may be notified of changes. | Back to list |
When using a ClassMap Fluent NH wraps the table name in square brackets by default. This breaks NH SchemaUpdate because SchemaUpdates searches for existing tables using the wrapped name as is. That is, a class Foo will be mapped as <class name="Foo" table="[Foo]" xmlns="...">. The schema updater will later try to find a table named "[Foo]" which is not available (whereas "Foo" is). An example query, logged with SQL Server Profiler: exec sp_executesql N'select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE from INFORMATION_SCHEMA.TABLES where (TABLE_CATALOG = @Catalog or (@Catalog is null)) and (TABLE_SCHEMA = @Owner or (@Owner is null)) and (TABLE_NAME = @Name or (@Name is null)) and (TABLE_TYPE = @TableType or (@TableType is null))', N'@Catalog nvarchar(4000),@Owner nvarchar(4000),@Name nvarchar(6),@TableType nvarchar(4000)', @Catalog=NULL, @Owner=NULL, @Name=N'[Foo]', <-- square brackets @TableType=NULL Please note that I'm a NH beginner, and I'm note sure if this is a problem in NH ider FNH. However, when I changed ClassMap such that tables will be wrapped in `TableName` the problem went away. |
|
,
Oct 15, 2008
The way fluent-nhib's tables are escaped was a hack, I believe. The backtick is the correct method for escaping tables in NHibernate, so we should really use that method.
Status: Accepted
|
|
,
Oct 22, 2008
I've attached a patch. |
|
,
Nov 02, 2008
Please review the updated patch (which is attached). It makes sure that not only table names are escaped, but also column names. If you are aware of other attributes that may require escaping, please add them to to the list of attributes in StringExtensions.cs. |
|
,
Dec 14, 2008
(No comment was entered for this change.)
Summary: Escaped column names
|
|
,
Jan 03, 2009
I believe this has been implemented, please reopen if this is not the case.
Status: Fixed
|
|
,
Jan 04, 2009
This has been implemented for table names, but not for column names in the current trunk. The fix should be an easy one using EscapeTablesAndColumnNames.patch. Since that patch has been generated for an older version of the trunk there might be some additional work involved (like adjusting new tests), but I have been using it along with some other refinements without having any problems. Given the things I said above, do I have to do anything else to re-open the ticket? |
|
,
Jan 05, 2009
Good point, I was unaware that we hadn't implemented the fix for column names. Reopened.
Status: Accepted
|
|
,
Jan 08, 2009
Waiting on this guy :) |
|
,
Mar 15, 2009
I'm using Fluent NH for mapping and NH as ORM in my C# application.. The problem is with schemaupdate class.. if I create an instance of that.. using the configuration I got from my exposeconfiguration function.. It doesnot update the schema.. I need some better documentation on SchemaUpdate class.. or might be.. setting the configuration to accomodate the new schema in an old database.. for versioning purposes.. I have tried a lot of variations but no DDL command is reflected on the actual database using SchemaUpdate :( |
|
,
Apr 25, 2009
(No comment was entered for this change.)
Summary: Bug: Escaped column names
|
|
|
|