Can't convert infinite timestamp values to DateTime" PostgreSQL

Posts   
 
    
hankddog
User
Posts: 52
Joined: 08-Apr-2005
# Posted on: 20-Jun-2018 16:52:13   

I am doing a fetch on a User entity and it is returning 'Can't convert infinite timestamp values to DateTime' An exception of type 'System.InvalidCastException' occurred in SD.LLBLGen.Pro.ORMSupportClasses.dll but was not handled in user code

The database is PostgreSQL.

The column is a timestamp.

The attachment can show you my settings. I even tried to use the built-in converter. I have the latest build V5.4.1 from June 18th

Attachments
Filename File size Added on Approval
6-20-2018 10-51-33 AM.png 31,994 20-Jun-2018 16:52.28 Approved
Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 20-Jun-2018 20:07:18   

Could you please provide the stackTrace?

hankddog
User
Posts: 52
Joined: 08-Apr-2005
# Posted on: 21-Jun-2018 16:04:56   

Walaa wrote:

Could you please provide the stackTrace?

at Npgsql.NpgsqlDataReader.GetValue(Int32 ordinal) at Npgsql.NpgsqlDataReader.GetValues(Object[] values) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore.FetchOneRow(IDataReader dataSource, IEntityFields2 rowDestination, IFieldPersistenceInfo[] fieldsPersistenceInfo) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore.ExecuteSingleRowRetrievalQuery(IRetrievalQuery queryToExecute, IEntityFields2 fieldsToFill, IFieldPersistenceInfo[] fieldsPersistenceInfo) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore.FetchEntityUsingFilter(IEntityFields2 fieldsToFetch, IFieldPersistenceInfo[] persistenceInfos, IRelationPredicateBucket filter) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore.FetchEntityUsingFilter(IEntity2 entityToFetch, IPrefetchPath2 prefetchPath, Context contextToUse, IRelationPredicateBucket filter, ExcludeIncludeFieldsList excludedIncludedFields) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore.FetchEntity(IEntity2 entityToFetch, IPrefetchPath2 prefetchPath, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.<>c__DisplayClass9_0.<FetchEntity>b__0() at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.ExecuteWithActiveRecoveryStrategy[T](Func1 toExecute) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntity(IEntity2 entityToFetch, IPrefetchPath2 prefetchPath, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore.FetchEntity(IEntity2 entityToFetch) at BRL.MVC.EntityClass.UserBL.Get(Nullable1 id) in C:\Users\mark\Source\Repos\WoodworkService\BRL.MVC\EntityClass\UserBL.cs:line 29 at BRL.MVC.ScheduledTasks.DeletedUsersSync.CheckDeletedUsers() in C:\Users\mark\Source\Repos\WoodworkService\BRL.MVC\ScheduledTasks\DeletedUsersSync.cs:line 72 at DevApplication.Default.btnTest_Click(Object sender, EventArgs e) in C:\Users\mark\Source\Repos\WoodworkService\DevApplication\Default.aspx.cs:line 22 at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

I am using Npgsql 3.2.7

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 22-Jun-2018 00:01:35   

The exceptions occurs inside Npgsql. A quick googling shows it's an issue in Npgsql.

hankddog
User
Posts: 52
Joined: 08-Apr-2005
# Posted on: 22-Jun-2018 17:47:46   

Walaa wrote:

The exceptions occurs inside Npgsql. A quick googling shows it's an issue in Npgsql.

https://github.com/npgsql/npgsql/issues/1324

So there is no workaround inside LLBLGen Pro? I can save those fields. Its when I bring back the entity bombs out.

hankddog
User
Posts: 52
Joined: 08-Apr-2005
# Posted on: 22-Jun-2018 18:17:25   

hankddog wrote:

Walaa wrote:

The exceptions occurs inside Npgsql. A quick googling shows it's an issue in Npgsql.

https://github.com/npgsql/npgsql/issues/1324

So there is no workaround inside LLBLGen Pro? I can save those fields. Its when I bring back the entity bombs out.

I answered my own questions. smile

I just excluded the bad fields on the fetch

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 23-Jun-2018 09:52:50   

I can imagine it's not always a good solution. reading the github issue, I think Roji is a bit dismissive here, it is a valid use case and IMHO it should just work (as in: use the type that fits the value, not throw an exception).

It's the same thing as with Oracle and decimal overflow in ODP.NET. When reading a NUMBER(10,38 ) for instance, it will bomb at runtime as it can't fit in a System.Decimal. We implemented a way to handle this, albeit using exception handling as control flow, so it has a bit of a performance hit.

See: https://www.llblgen.com/Documentation/5.4/ReferenceManuals/LLBLGenProRTF/html/3F710BF4.htm

In a partial class of DataAccessAdapter, override this method, and you can locally handle the exception when the read occurs. E.g. use a provider specific method (like suggested in the issue) to read the column. It's very specific though, so it's not a 'general handler' function, so it's meant as a last resort, for when you need to fetch these types but are unable to do so. It's not simple to determine which column failed (as that's not in the exception and we read all columns in one go with GetValues()) so you have to add specific logic in that method for that, hence the specific nature.

That said, it would be better if Npgsql simply did the right thing here and wrapped the value in the Npgsql specific type if anything. Throwing an exception is never a good thing. I'll follow up on this in the GH issue, as I think it's better to wrap it in a proper type than an exception.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 25-Jun-2018 17:14:02   

There's some help when you override that method, you can use DbDataReader.GetProviderSpecificValues() to obtain the values in the array in the specific types. It's not ideal but it can help a bit. See also the github issue for details.

Frans Bouma | Lead developer LLBLGen Pro