Fluent NHibernate quotes all fields?

254 views
Skip to first unread message

Doron Yaacoby

unread,
Jan 23, 2010, 2:21:35 PM1/23/10
to Fluent NHibernate
Hi,
Using the latest trunk version of FNH, it seems to be quoting all
field names in the mappings. This doesn't happen in the version 1 RTM.
Is this by design?

Thanks,
Doron

James Gregory

unread,
Jan 23, 2010, 2:22:26 PM1/23/10
to fluent-n...@googlegroups.com
Yep, by design. Why?


--
You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group.
To post to this group, send email to fluent-n...@googlegroups.com.
To unsubscribe from this group, send email to fluent-nhibern...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.


Doron Yaacoby

unread,
Jan 23, 2010, 2:28:44 PM1/23/10
to Fluent NHibernate
Since all my queries now fail, as my tables in the database (Oracle)
were created without quotes in the field names. Is there a way to turn
the quoting off?

On Jan 23, 9:22 pm, James Gregory <jagregory....@gmail.com> wrote:
> Yep, by design. Why?
>

> On Sat, Jan 23, 2010 at 7:21 PM, Doron Yaacoby <ya.do...@gmail.com> wrote:
> > Hi,
> > Using the latest trunk version of FNH, it seems to be quoting all
> > field names in the mappings. This doesn't happen in the version 1 RTM.
> > Is this by design?
>
> > Thanks,
> > Doron
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Fluent NHibernate" group.
> > To post to this group, send email to fluent-n...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > fluent-nhibern...@googlegroups.com<fluent-nhibernate%2Bunsu...@googlegroups.com>

Hudson Akridge

unread,
Jan 23, 2010, 2:30:38 PM1/23/10
to fluent-n...@googlegroups.com
Why do we have quoting for the column/table names?

To unsubscribe from this group, send email to fluent-nhibern...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.




--
- Hudson
http://www.bestguesstheory.com
http://twitter.com/HudsonAkridge

James Gregory

unread,
Jan 23, 2010, 2:48:54 PM1/23/10
to fluent-n...@googlegroups.com
Your queries shouldn't fail, unless oracle is really badly designed. The quoting simply affects the queries, and is used to escape keywords. At least in SQL Server [Customer] is exactly the same as Customer in a query, and has no effect to the underlying schema.

To unsubscribe from this group, send email to fluent-nhibern...@googlegroups.com.

James Gregory

unread,
Jan 23, 2010, 2:49:12 PM1/23/10
to fluent-n...@googlegroups.com
Why not?

Hudson Akridge

unread,
Jan 23, 2010, 2:51:06 PM1/23/10
to fluent-n...@googlegroups.com
Ah, I see what you're talking about now. I was thinking quoting in another way. Carry on :)

Doron Yaacoby

unread,
Jan 23, 2010, 3:03:19 PM1/23/10
to Fluent NHibernate
Well,
In Oracle quoting a table or a column name makes it case-sensitive.
So select * from "Customer" != select * from customer. Hence, the
failing queries.

I also noticed that FNH quotes table names as well, but that can be
overcome by explicitly specifing the table name in the mappings. It
doesn't work for columns, though.

On Jan 23, 9:48 pm, James Gregory <jagregory....@gmail.com> wrote:
> Your queries shouldn't fail, unless oracle is really badly designed. The
> quoting simply affects the queries, and is used to escape keywords. At least
> in SQL Server [Customer] is exactly the same as Customer in a query, and has
> no effect to the underlying schema.
>

> On Sat, Jan 23, 2010 at 7:28 PM, Doron Yaacoby <ya.do...@gmail.com> wrote:
> > Since all my queries now fail, as my tables in the database (Oracle)
> > were created without quotes in the field names. Is there a way to turn
> > the quoting off?
>
> > On Jan 23, 9:22 pm, James Gregory <jagregory....@gmail.com> wrote:
> > > Yep, by design. Why?
>
> > > On Sat, Jan 23, 2010 at 7:21 PM, Doron Yaacoby <ya.do...@gmail.com>
> > wrote:
> > > > Hi,
> > > > Using the latest trunk version of FNH, it seems to be quoting all
> > > > field names in the mappings. This doesn't happen in the version 1 RTM.
> > > > Is this by design?
>
> > > > Thanks,
> > > > Doron
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Fluent NHibernate" group.
> > > > To post to this group, send email to
> > fluent-n...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > fluent-nhibern...@googlegroups.com<fluent-nhibernate%2Bunsu...@googlegroups.com>

> > <fluent-nhibernate%2Bunsu...@googlegroups.com<fluent-nhibernate%252Buns...@googlegroups.com>

James Gregory

unread,
Jan 23, 2010, 3:08:52 PM1/23/10
to fluent-n...@googlegroups.com
Looks like I need to review this again then. In the mean time you'll need to modify the code yourself to undo my change :(

XmlColumnWriter is the class you need to change, you should see the code for writing out the name attribute appends the backticks.

I'll try to come up with a more manageable solution; maybe a setting or something.

To unsubscribe from this group, send email to fluent-nhibern...@googlegroups.com.

Doron Yaacoby

unread,
Jan 23, 2010, 3:10:32 PM1/23/10
to Fluent NHibernate
Sure thing. Thanks for the tip.

On Jan 23, 10:08 pm, James Gregory <jagregory....@gmail.com> wrote:
> Looks like I need to review this again then. In the mean time you'll need to
> modify the code yourself to undo my change :(
>
> XmlColumnWriter is the class you need to change, you should see the code for
> writing out the name attribute appends the backticks.
>
> I'll try to come up with a more manageable solution; maybe a setting or
> something.
>

> > > > <fluent-nhibernate%2Bunsu...@googlegroups.com<fluent-nhibernate%252Buns...@googlegroups.com>
> > <fluent-nhibernate%252Buns...@googlegroups.com<fluent-nhibernate%25252Bun...@googlegroups.com>

Pci

unread,
Jan 28, 2010, 2:16:33 PM1/28/10
to Fluent NHibernate
Yeah, this quoting thing it's an issue too when using things like
Formulas and/or Checks..

Specially on PostgreSQL which is case sensitive when using quotes, but
insensitive when not. This forces us to quote every identifier on each
formular definition, but then NH get's confused and makes weird things
like this:

Formula: "(SELECT SUM(b.`Credit`) FROM `BusinessUnits` b WHERE
b.`OwnerId`=`Id`)"

Result: (SELECT SUM(b.this_."Credit") FROM this_."BusinessUnits" b
WHERE b.this_."OwnerId"=this_."Id")

W/o quoting tables/columns there's no need to quote identifiers on
formulas.. and so there's no problem at all.

Initally I thoung on adding some kind of global property to
FluentConfiguration which disabled quoting at all, but AFAIK from
XmlColumnWriter you cannot access FluentConfiguration nor any other
global structure.. so I have nothing on which I can really to know if
the user wants quoting or not.

On Jan 23, 9:10 pm, Doron Yaacoby <ya.do...@gmail.com> wrote:
> Sure thing. Thanks for the tip.
>
> On Jan 23, 10:08 pm, James Gregory <jagregory....@gmail.com> wrote:
>
>
>
> > Looks like I need to review this again then. In the mean time you'll need to
> > modify the code yourself to undo my change :(
>
> > XmlColumnWriter is the class you need to change, you should see the code for
> > writing out the name attribute appends the backticks.
>
> > I'll try to come up with a more manageable solution; maybe a setting or
> > something.
>
> > On Sat, Jan 23, 2010 at 8:03 PM, Doron Yaacoby <ya.do...@gmail.com> wrote:
> > > Well,
> > > In Oracle quoting a table or a column name makes it case-sensitive.
> > > So select * from "Customer" != select * from customer. Hence, the
> > > failing queries.
>

> > > I also noticed that FNHquotestable names as well, but that can be


> > > overcome by explicitly specifing the table name in the mappings. It
> > > doesn't work for columns, though.
>
> > > On Jan 23, 9:48 pm, James Gregory <jagregory....@gmail.com> wrote:
> > > > Your queries shouldn't fail, unless oracle is really badly designed. The
> > > > quoting simply affects the queries, and is used to escape keywords. At
> > > least
> > > > in SQL Server [Customer] is exactly the same as Customer in a query, and
> > > has
> > > > no effect to the underlying schema.
>
> > > > On Sat, Jan 23, 2010 at 7:28 PM, Doron Yaacoby <ya.do...@gmail.com>
> > > wrote:
> > > > > Since all my queries now fail, as my tables in the database (Oracle)

> > > > > were created withoutquotesin the field names. Is there a way to turn


> > > > > the quoting off?
>
> > > > > On Jan 23, 9:22 pm, James Gregory <jagregory....@gmail.com> wrote:
> > > > > > Yep, by design. Why?
>
> > > > > > On Sat, Jan 23, 2010 at 7:21 PM, Doron Yaacoby <ya.do...@gmail.com>
> > > > > wrote:
> > > > > > > Hi,
> > > > > > > Using the latest trunk version of FNH, it seems to be quoting all
> > > > > > > field names in the mappings. This doesn't happen in the version 1
> > > RTM.
> > > > > > > Is this by design?
>
> > > > > > > Thanks,
> > > > > > > Doron
>
> > > > > > > --
> > > > > > > You received this message because you are subscribed to the Google
> > > > > Groups
> > > > > > > "Fluent NHibernate" group.
> > > > > > > To post to this group, send email to
> > > > > fluent-n...@googlegroups.com.
> > > > > > > To unsubscribe from this group, send email to

> > > > > > > fluent-nhibern...@googlegroups.com<fluent-nhibernate%2Bunsubscr i...@googlegroups.com>
> > > <fluent-nhibernate%2Bunsu...@googlegroups.com<fluent-nhibernate%252Buns ubsc...@googlegroups.com>
>
> > > > > <fluent-nhibernate%2Bunsu...@googlegroups.com<fluent-nhibernate%252Buns ubsc...@googlegroups.com>
> > > <fluent-nhibernate%252Buns...@googlegroups.com<fluent-nhibernate%25252 Bunsub...@googlegroups.com>


>
> > > > > > > .
> > > > > > > For more options, visit this group at
> > > > > > >http://groups.google.com/group/fluent-nhibernate?hl=en.
>
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > Groups
> > > > > "Fluent NHibernate" group.
> > > > > To post to this group, send email to
> > > fluent-n...@googlegroups.com.
> > > > > To unsubscribe from this group, send email to

> > > > > fluent-nhibern...@googlegroups.com<fluent-nhibernate%2Bunsubscr i...@googlegroups.com>
> > > <fluent-nhibernate%2Bunsu...@googlegroups.com<fluent-nhibernate%252Buns ubsc...@googlegroups.com>


>
> > > > > .
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/fluent-nhibernate?hl=en.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Fluent NHibernate" group.
> > > To post to this group, send email to fluent-n...@googlegroups.com.
> > > To unsubscribe from this group, send email to

> > > fluent-nhibern...@googlegroups.com<fluent-nhibernate%2Bunsubscr i...@googlegroups.com>

James Gregory

unread,
Jan 28, 2010, 2:20:19 PM1/28/10
to fluent-n...@googlegroups.com
Yeah, I was thinking of something similar. I think for the time being I'll just undo the offending change until we can come up with a less harmful change.

To unsubscribe from this group, send email to fluent-nhibern...@googlegroups.com.

David R. Longnecker

unread,
Jan 28, 2010, 4:56:57 PM1/28/10
to fluent-n...@googlegroups.com
Oh, I should read my email... damn gmail filters. I wouldn't have twit-tormented James about this earlier. ;)

Anyway, I've updated the XmlColumnWriter in my fork and things are dandy.  "`" + name + "`" == evil.

I can see value in being able to auto-quote, but I'm not sure how to get at it.  Someone with more experience with the deep bits of MappingBase/IMappingProvider (maybe adding a 'WithQuotes' bool or something) and apply to OneToOneMapping and ClassMap.

-dl

---
David R. Longnecker
blog: http://blog.drlongnecker.com
twitter: dlongnecker

Chris C

unread,
Jan 29, 2010, 7:28:48 AM1/29/10
to Fluent NHibernate
Should quoting fields like this be the responsibility of Fluent
NHibernate? What about using hbm2ddl.keywords and
SchemaMetadataUpdater as demonstrated in
http://fabiomaulo.blogspot.com/2009/06/auto-quote-tablecolumn-names.html
?

With an opt-in/out option for its use as part of the fluent
configuration.

On 28 Jan, 21:56, "David R. Longnecker" <drlongnec...@gmail.com>
wrote:


> Oh, I should read my email... damn gmail filters. I wouldn't have
> twit-tormented James about this earlier. ;)
>
> Anyway, I've updated the XmlColumnWriter in my fork and things are dandy.
> "`" + name + "`" == evil.
>
> I can see value in being able to auto-quote, but I'm not sure how to get at
> it.  Someone with more experience with the deep bits of
> MappingBase/IMappingProvider (maybe adding a 'WithQuotes' bool or something)
> and apply to OneToOneMapping and ClassMap.
>
> -dl
>
> ---
> David R. Longnecker
> blog:http://blog.drlongnecker.com
> twitter: dlongnecker
>

> On Thu, Jan 28, 2010 at 1:20 PM, James Gregory <jagregory....@gmail.com>wrote:
>
>
>
> > Yeah, I was thinking of something similar. I think for the time being I'll
> > just undo the offending change until we can come up with a less harmful
> > change.
>

> >> > > > > > > > fluent-nhibern...@googlegroups.com<fluent-nhibernate%2Bunsubscr i...@googlegroups.com><fluent-nhibernate%2Bunsubscr
> >> i...@googlegroups.com>
> >> > > > <fluent-nhibernate%2Bunsu...@googlegroups.com<fluent-nhibernate%252Buns ubsc...@googlegroups.com><fluent-nhibernate%252Buns
> >> ubsc...@googlegroups.com>
>
> >> > > > > > <fluent-nhibernate%2Bunsu...@googlegroups.com<fluent-nhibernate%252Buns ubsc...@googlegroups.com><fluent-nhibernate%252Buns
> >> ubsc...@googlegroups.com>
> >> > > > <fluent-nhibernate%252Buns...@googlegroups.com<fluent-nhibernate%25252 Bunsub...@googlegroups.com><fluent-nhibernate%25252


> >> Bunsub...@googlegroups.com>
>
> >> > > > > > > > .
> >> > > > > > > > For more options, visit this group at
> >> > > > > > > >http://groups.google.com/group/fluent-nhibernate?hl=en.
>
> >> > > > > > --
> >> > > > > > You received this message because you are subscribed to the
> >> Google
> >> > > > Groups
> >> > > > > > "Fluent NHibernate" group.
> >> > > > > > To post to this group, send email to
> >> > > > fluent-n...@googlegroups.com.
> >> > > > > > To unsubscribe from this group, send email to

> >> > > > > > fluent-nhibern...@googlegroups.com<fluent-nhibernate%2Bunsubscr i...@googlegroups.com><fluent-nhibernate%2Bunsubscr
> >> i...@googlegroups.com>
> >> > > > <fluent-nhibernate%2Bunsu...@googlegroups.com<fluent-nhibernate%252Buns ubsc...@googlegroups.com><fluent-nhibernate%252Buns


> >> ubsc...@googlegroups.com>
>
> >> > > > > > .
> >> > > > > > For more options, visit this group at
> >> > > > > >http://groups.google.com/group/fluent-nhibernate?hl=en.
>
> >> > > > --
> >> > > > You received this message because you are subscribed to the Google
> >> Groups
> >> > > > "Fluent NHibernate" group.
> >> > > > To post to this group, send email to
> >> fluent-n...@googlegroups.com.
> >> > > > To unsubscribe from this group, send email to

> >> > > > fluent-nhibern...@googlegroups.com<fluent-nhibernate%2Bunsubscr i...@googlegroups.com><fluent-nhibernate%2Bunsubscr

Reply all
Reply to author
Forward
0 new messages