recent breaking change in CustomTypeIs

12 views
Skip to first unread message

Rob

unread,
May 4, 2009, 4:20:48 PM5/4/09
to Fluent NHibernate
I have mappings like this: CustomTypeIs("Date")
Since revision 458 such thing does not compile.
Is this change intentional or accidental? I mean: should I change my
own code (CustomSqlTypeIs(Date) or
CustomTypeIs<NHibernate.Type.DateType() ) or should I open a new
issue?

Robert

Hudson Akridge

unread,
May 4, 2009, 4:25:02 PM5/4/09
to fluent-n...@googlegroups.com
I'm not 100% on whether or not this was accidental or intentional, since I'm a bit behind the curve on the new SM.

458 was the merge with the new model for Fluent, so it's possible that this broke a few things. Please submit a bug report with as much detail as you can muster, as our priority is currently to make sure that things that worked pre-merge, work post-merge. Meaning it would be a high priority for us.

James Gregory

unread,
May 4, 2009, 4:37:27 PM5/4/09
to fluent-n...@googlegroups.com
Is there a reason you're using the string method over one of the others?

robsosno

unread,
May 4, 2009, 5:10:44 PM5/4/09
to fluent-n...@googlegroups.com
James Gregory pisze:
I've just created new issue:
http://code.google.com/p/fluent-nhibernate/issues/detail?id=212
I've described there the reasons I'm using this form.
In general I need that SchemaExport will report correct type for my
database (Informix).
So CustomTypeIs("Date") should generate column of "Date" type and
CustomTypeIs("Decimal(16,2)") should generate "Decimal(16,2):
column1 Date,
column2 decimal(16,2), ...

On the other hand I need that SchemaExport generate for SQLite in-memory
database something like this:
column1 DateTime,
column2 Numeric, ...

In other words: string method is the only way to specify more detail
about sql type in a portable way.

James Gregory

unread,
May 4, 2009, 5:17:23 PM5/4/09
to fluent-n...@googlegroups.com
If you're using it specifically for setting the sql type, CustomSqlTypeIs would be the better method to call. CustomTypeIs is used for overriding the type of the actual property, mainly for using IUserType implementations.

2009/5/4 robsosno <robs...@gmail.com>

robsosno

unread,
May 5, 2009, 3:11:44 PM5/5/09
to fluent-n...@googlegroups.com
I can write CustomSqlTypeIs("Date") or CustomSqlTypeIs("Decimal(16,2)").
This is correct for my database.
However this way I'll break my unit tests which are executed using
SQLite in-memory database (CustomSqlTypeIs("DateTime") and
CustomSqlTypeIs("Numeric")).

I would use rather this: CustomTypeIs<NHibernate.Type.DateType>()
and for the second case I need this:
CustomTypeIs<NHibernate.Type.DecimalType>(scale, precision)
or rather:

CustomTypeIs<NHibernate.Type.DecimalType>().WithScaleOf(scale).WithPrecisionOf(precision)
// analogues to WithLengthOf
but such options do not exist yet.

James Gregory pisze:
> If you're using it specifically for setting the sql type,
> CustomSqlTypeIs would be the better method to call. CustomTypeIs is
> used for overriding the type of the actual property, mainly for using
> IUserType implementations.
>
> 2009/5/4 robsosno <robs...@gmail.com <mailto:robs...@gmail.com>>
>
>
> James Gregory pisze:
> > Is there a reason you're using the string method over one of the
> others?
> >
> > On Monday, May 4, 2009, Hudson Akridge <hudson....@gmail.com

James Gregory

unread,
May 5, 2009, 5:13:27 PM5/5/09
to fluent-n...@googlegroups.com
It seems like you're asking for more than one thing. Lets straighten the first one out, CustomTypeIs(string) is gone, can you use CustomSqlTypeIs(string) instead?

2009/5/5 robsosno <robs...@gmail.com>

robsosno

unread,
May 6, 2009, 3:41:39 PM5/6/09
to fluent-n...@googlegroups.com
I've already explained this: CustomSqlTypeIs(string) is not an option -
it works for single database type only, and I have two databases: for
unit tests and production one.
I see solution for the case: CustomTypeIs("Date") - it is just
CustomTypeIs<NHibernate.Type.DateType>().

However for CustomTypeIs("Decimal(16,2)") I still have a problem.
I've found possble solutions:
1.
if (IsProductionDatabase) {
Map(x =>x.Balance).CustomSqlTypeIs("Decimal(16,2)");
} else { // unit tests
Map(x =>x.Balance).CustomSqlTypeIs("Numeric");
}
- possible but ugly

2.
Map(x =>x.Balance).SetAttribute("type","decimal(16,3)");
- because I have plenty of SetAttribute in the mapping anyway this
doesn't seem to be that bad

3.
Map(x =>x.Balance).WithScaleOf(16).WithPrecisionOf(3);
- perfect solution but currently not available;

4.
Map(x =>x.Balance).CustomTypeIs("Decimal(16,2)");
- using old revision of FNH

I'm leaning to the solution no 2. But this is worse than the old way.
Could you just revert CustomTypeIs(string) until option 3 will become
available?
I agree that better is to use strongly typed version where possible. For
this purpose you can decorate the method with the [Obsolete] attribute.


Robert


James Gregory pisze:
> It seems like you're asking for more than one thing. Lets straighten
> the first one out, CustomTypeIs(string) is gone, can you use
> CustomSqlTypeIs(string) instead?
>
> 2009/5/5 robsosno <robs...@gmail.com <mailto:robs...@gmail.com>>
>
>
> I can write CustomSqlTypeIs("Date") or
> CustomSqlTypeIs("Decimal(16,2)").
> This is correct for my database.
> However this way I'll break my unit tests which are executed using
> SQLite in-memory database (CustomSqlTypeIs("DateTime") and
> CustomSqlTypeIs("Numeric")).
>
> I would use rather this: CustomTypeIs<NHibernate.Type.DateType>()
> and for the second case I need this:
> CustomTypeIs<NHibernate.Type.DecimalType>(scale, precision)
> or rather:
>
> CustomTypeIs<NHibernate.Type.DecimalType>().WithScaleOf(scale).WithPrecisionOf(precision)
> // analogues to WithLengthOf
> but such options do not exist yet.
>
> James Gregory pisze:
> > If you're using it specifically for setting the sql type,
> > CustomSqlTypeIs would be the better method to call. CustomTypeIs is
> > used for overriding the type of the actual property, mainly for
> using
> > IUserType implementations.
> >
> > 2009/5/4 robsosno <robs...@gmail.com
> <mailto:robs...@gmail.com> <mailto:robs...@gmail.com
> <mailto:robs...@gmail.com>>>
> >
> >
> > James Gregory pisze:
> > > Is there a reason you're using the string method over one
> of the
> > others?
> > >
> > > On Monday, May 4, 2009, Hudson Akridge
> <hudson....@gmail.com <mailto:hudson....@gmail.com>
> > <mailto:hudson....@gmail.com
> <mailto:hudson....@gmail.com>>> wrote:
> > >
> > >> I'm not 100% on whether or not this was accidental or
> > intentional, since I'm a bit behind the curve on the new SM.
> > >> 458 was the merge with the new model for Fluent, so it's
> > possible that this broke a few things. Please submit a bug
> report
> > with as much detail as you can muster, as our priority is
> > currently to make sure that things that worked pre-merge, work
> > post-merge. Meaning it would be a high priority for us.
> > >>
> > >> On Mon, May 4, 2009 at 3:20 PM, Rob <robs...@gmail.com
> <mailto:robs...@gmail.com>

James Gregory

unread,
May 8, 2009, 5:31:30 AM5/8/09
to fluent-n...@googlegroups.com
Reverted. You should be able to use the string overload again.

2009/5/6 robsosno <robs...@gmail.com>

robsosno

unread,
May 10, 2009, 2:39:28 PM5/10/09
to fluent-n...@googlegroups.com
Thank you! I appreciate that you listen to users although I'm aware that
it is not easy.

In the meantime I've tried to replace CustomTypeIs("Date") with
CustomTypeIs<DateType>().
I've got some problems (error "Could not instantiate IType DateType:
System.MissingMethodException: No parameterless constructor defined for
this object.
" if you are curious).
This is not a FNH issue. I'll ask NHibernate guys to fix this. IMO if
CustomTypeIs("<type>") works then CustomTypeIs<type>() should also work.

Robert

James Gregory pisze:
> Reverted. You should be able to use the string overload again.
>
> 2009/5/6 robsosno <robs...@gmail.com <mailto:robs...@gmail.com>>
> <mailto:robs...@gmail.com> <mailto:robs...@gmail.com
> > <mailto:robs...@gmail.com <mailto:robs...@gmail.com>>>>
Reply all
Reply to author
Forward
0 new messages