SQL Server image field max length issue with synonyms

Posts   
 
    
derrick
User
Posts: 40
Joined: 14-Jan-2004
# Posted on: 13-Aug-2015 16:55:16   

Hi,

I am having an issue that I think is a bug.

I have a large table that I want to move to another database. I moved it, then created a synonym to it with the same name. After I refreshed the relational model from the database I noticed the image field was given a max length of 16. It was 2147483647 when mapped directly to the table. Now when I attempt to save an entity mapped to the synonym I get an exception due to the 16 byte size restriction. I also noticed that if I edit the field mapping to the image field in the designer, then change it's type in the dropdown, then change it back to image, the size changes to 2147483647. Unfortunately the next time I refresh the model from the database it changes it back to 16.

Is this a bug?

Derrick

LLBLGen 4.2 Final, August 2nd, 2015 Adapter template .Net 4.5.2 Microsoft SQL Server 2008 R2 (RTM) - 10.50.1617.0 (X64) Apr 22 2011 19:23:43 Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39866
Joined: 17-Aug-2003
# Posted on: 13-Aug-2015 17:22:39   

Please give the table and synonym definition in DDL SQL so we can try to reproduce it. The synonym is in another schema?

Frans Bouma | Lead developer LLBLGen Pro
derrick
User
Posts: 40
Joined: 14-Jan-2004
# Posted on: 13-Aug-2015 17:29:53   

The synonym is in the schema that is the source of my model. Here's the DDL for each.

USE [lhotse2] GO

CREATE TABLE [dbo].[lhotse_media]( [media_num] [INT] IDENTITY(1,1) NOT NULL, [created_dttm] [DATETIME] NOT NULL, [modified_dttm] [DATETIME] NOT NULL, [reguser_num_creator] [INT] NOT NULL, [reguser_num_modifier] [INT] NOT NULL, [media_name] VARCHAR NOT NULL, [media_size] [INT] NOT NULL, [media_mime_type] VARCHAR NOT NULL, [status_cd] VARCHAR NOT NULL, [media_data] [IMAGE] NOT NULL, [media_thumbnail_data] [IMAGE] NULL, [media_description] VARCHAR NULL, [media_thumbnail_size] [INT] NULL, [media_kind_cd] VARCHAR NOT NULL, CONSTRAINT [PK_media] PRIMARY KEY CLUSTERED ( [media_num] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 80) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

USE [lhotse] GO

/****** Object: Synonym [dbo].[lhotse_media] Script Date: 08/13/2015 11:26:46 ******/ CREATE SYNONYM [dbo].[lhotse_media] FOR [lhotse2].[dbo].[lhotse_media] GO

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 13-Aug-2015 23:35:26   

Reproduced.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39866
Joined: 17-Aug-2003
# Posted on: 14-Aug-2015 13:59:12   

The column layout of the query used is different, and we rely on max_length in the column definition, while in the table field query we use information_schema's views, which return a different value (16 vs 2^31-1). As synonyms can be in another catalog we can't use information schema for synonyms so we use sys.columns instead. We'll look into obtaining the right information properly.

(edit) there are other issues as well, max_length reports bytes, but nvarchar types of course have 2-bytes per char (or more). The character max length is therefore different, but that info isn't available in that system view and those values are wrong too.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39866
Joined: 17-Aug-2003
# Posted on: 14-Aug-2015 14:41:17   

Fixed, see attached debug build for the sql server driver. Please copy this dll as administrator(!) over the existing driver in <installation folder>\Drivers\SqlServer

Attachments
Filename File size Added on Approval
SD.LLBLGen.Pro.DBDrivers.SqlServerDBDriver.dll 98,304 14-Aug-2015 14:41.25 Approved
Frans Bouma | Lead developer LLBLGen Pro
derrick
User
Posts: 40
Joined: 14-Jan-2004
# Posted on: 14-Aug-2015 15:41:32   

Thanks for the quick turn around on a patch. I did save the DLL as you mentioned but when I open my project in the designer I get the following exception. Did the driverID change?

Derrick

Exception information.

LLBLGen Pro version: v4.2. Build: August 2nd, 2015

Exception details:

Message: The XML contains a reference to a driver with ID: '2D18D138-1DD2-467E-86CC-4838250611AE' which isn't loaded, likely due to a missing ADO.NET provider. Source: SD.LLBLGen.Pro.ApplicationCore Stack trace: at SD.LLBLGen.Pro.ApplicationCore.MetaData.MetaDataStore.DeserializeTargetDatabase(XmlReader reader) at SD.LLBLGen.Pro.ApplicationCore.MetaData.MetaDataStore.DeserializeFromReader(XmlReader reader) at SD.LLBLGen.Pro.ApplicationCore.ProjectClasses.Project.DeserializeFromReader(XmlReader reader, String additionalTypeConverterFolder) at SD.LLBLGen.Pro.ApplicationCore.ProjectClasses.Project.Load(String filename, String additionalTypeConverterFolder) at SD.LLBLGen.Pro.Gui.Classes.GuiController.PerformOpenProjectAction(String filenameToOpen)

Inner exception: <null>

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39866
Joined: 17-Aug-2003
# Posted on: 14-Aug-2015 18:09:26   

Right-click the dll in windows explorer -> properties -> click 'unblock'. Likely it's blocked by windows as you downloaded it from the internet (and that's a scary place, according to windows wink )

Frans Bouma | Lead developer LLBLGen Pro
derrick
User
Posts: 40
Joined: 14-Jan-2004
# Posted on: 14-Aug-2015 19:43:35   

That was it. Thanks Frans. I've been a long time fan of the product.