Schema mix-up in generated code

Posts   
 
    
morten71
User
Posts: 80
Joined: 13-Jan-2009
# Posted on: 11-Oct-2010 15:45:02   

using v3 oct. 8 version

I have an issue where only one stored procedure named "dbo.GetActionUsers" is put into a different namespace in the generated code [Reports].[GetActionUsers].

In the sql 2005 db I have a schema named Reports.

I've tried to refresh and remove/add the stored procedure.

I was looking for an email to mail you a couple of screen shots.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 11-Oct-2010 15:59:13   

You can attach screen shots to this thread.

So are you saying that you have 2 different schema names in the same catalog?

morten71
User
Posts: 80
Joined: 13-Jan-2009
# Posted on: 11-Oct-2010 16:33:24   

Walaa wrote:

You can attach screen shots to this thread.

So are you saying that you have 2 different schema names in the same catalog?

I have the default dbo schema and a schma named Reports.

The stored proc resides in dbo but the code generated puts the stored proc in the Reports schema. Furthermore, the procedure is positioned as the first code in the list of Call Objects in the RetrievalProcedures class.

I'm thinking that it could either be some naming issue or an issue of some property in the GUI.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 11-Oct-2010 16:39:12   

Could you please attach a repro database script?

Which version (release date) of the designer are you using?

morten71
User
Posts: 80
Joined: 13-Jan-2009
# Posted on: 11-Oct-2010 23:56:39   

Walaa wrote:

Could you please attach a repro database script?

Which version (release date) of the designer are you using?

I dug a little deeper and it seems that the trouble is with stored procedures with no input parameters when the stored proc returns a resultset.

I can reproduce the issue the the code below. My LLBLGEN Oct. 8th, 2010 project: Target framework: LLBLGen Pro Runtime Framework Generated code: vb.net, .net 4, SelfServicing

use master
create database test1
go

use test1
create schema Reports
go

create table testTable (id int not null identity(1,1), name varchar(50))
alter table dbo.testTable add constraint pk_testTable primary key clustered (id)
go

insert into testTable (name) values ('n1')
insert into testTable (name) values ('n2')
insert into testTable (name) values ('n3')
go

create view viewTable as select name from testTable
go

create procedure [dbo].[test1]
AS
  select 1 as x
go

create procedure [dbo].[test2]
 @id int
AS
  select 1 as x
go

create procedure [Reports].[test3]
AS
  select 1 as x
go

create procedure [Reports].[test4]
 @id int
AS
  select 1 as x
go

paste from RetrievalProcedures.vb below:

    ''' <summary>Creates the Call Object For the Call 'Test3' to stored procedure 'test3'.</summary>
    ''' <param name="dataAccessProvider">The data access provider.</param>
    ''' <returns>Ready To use StoredProcedureCall Object</returns>
    Private Shared Function CreateTest3Call(dataAccessProvider As IDataAccessCore) As StoredProcedureCall
        Return New StoredProcedureCall(dataAccessProvider, "[test1].[dbo].[test3]", "Test3")
    End Function

    ''' <summary>Creates the Call Object For the Call 'Test4' to stored procedure 'test4'.</summary>
    ''' <param name="dataAccessProvider">The data access provider.</param>
    ''' <param name="id">Input parameter</param>
    ''' <returns>Ready To use StoredProcedureCall Object</returns>
    Private Shared Function CreateTest4Call(dataAccessProvider As IDataAccessCore, id As System.Int32) As StoredProcedureCall
        Return New StoredProcedureCall(dataAccessProvider, "[test1].[Reports].[test4]", "Test4") _ 
                        .AddParameter("@id", "Int", 0, ParameterDirection.Input, True, 10, 0, id)
    End Function

    ''' <summary>Creates the Call Object For the Call 'Test1' to stored procedure 'test1'.</summary>
    ''' <param name="dataAccessProvider">The data access provider.</param>
    ''' <returns>Ready To use StoredProcedureCall Object</returns>
    Private Shared Function CreateTest1Call(dataAccessProvider As IDataAccessCore) As StoredProcedureCall
        Return New StoredProcedureCall(dataAccessProvider, "[test1].[Reports].[test1]", "Test1")
    End Function

    ''' <summary>Creates the Call Object For the Call 'Test2' to stored procedure 'test2'.</summary>
    ''' <param name="dataAccessProvider">The data access provider.</param>
    ''' <param name="id">Input parameter</param>
    ''' <returns>Ready To use StoredProcedureCall Object</returns>
    Private Shared Function CreateTest2Call(dataAccessProvider As IDataAccessCore, id As System.Int32) As StoredProcedureCall
        Return New StoredProcedureCall(dataAccessProvider, "[test1].[dbo].[test2]", "Test2") _ 
                        .AddParameter("@id", "Int", 0, ParameterDirection.Input, True, 10, 0, id)
    End Function
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 12-Oct-2010 06:33:21   

Reproduced. Trying to find the reason...

(Edit) Seems to happen when you have two or more schemas and one of them have input parameters. I checked the templates, they are ok. We should investigate further...

(Edit) I can't reproduce it with similar scenario using AdventureWorks database.

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 12-Oct-2010 12:44:32   

very strange indeed! Will do some more tests to see what the problem is.

It doesn't relate to vb.net, it happens in C# too. It's not related to the fact multiple procs of the same schema are in the project...

Looking into it.

(edit) found it. It's related to a bug in the TDL interpreter. The statement <[SourceSchemaName]> checks if the current sub element mapping is null or not. it's not null due to a PREVIOUS loop over a previous proc with parameters. So it picks the schema of the containing element of the last parameter processed: that's wrong.

We'll work on a fix for this and get back to you a.s.a.p.

Frans Bouma | Lead developer LLBLGen Pro
morten71
User
Posts: 80
Joined: 13-Jan-2009
# Posted on: 12-Oct-2010 14:10:11   

Otis wrote:

very strange indeed! Will do some more tests to see what the problem is.

It doesn't relate to vb.net, it happens in C# too. It's not related to the fact multiple procs of the same schema are in the project...

Looking into it.

(edit) found it. It's related to a bug in the TDL interpreter. The statement <[SourceSchemaName]> checks if the current sub element mapping is null or not. it's not null due to a PREVIOUS loop over a previous proc with parameters. So it picks the schema of the containing element of the last parameter processed: that's wrong.

We'll work on a fix for this and get back to you a.s.a.p.

Thank you very much. It's a fantastic tool and the documentation, knowledge and support is outstanding. Really happy I upgraded to llblgen (looong time RapTier user)

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 12-Oct-2010 17:00:11   

morten71 wrote:

Otis wrote:

very strange indeed! Will do some more tests to see what the problem is.

It doesn't relate to vb.net, it happens in C# too. It's not related to the fact multiple procs of the same schema are in the project...

Looking into it.

(edit) found it. It's related to a bug in the TDL interpreter. The statement <[SourceSchemaName]> checks if the current sub element mapping is null or not. it's not null due to a PREVIOUS loop over a previous proc with parameters. So it picks the schema of the containing element of the last parameter processed: that's wrong.

We'll work on a fix for this and get back to you a.s.a.p.

Thank you very much. It's a fantastic tool and the documentation, knowledge and support is outstanding. Really happy I upgraded to llblgen (looong time RapTier user)

Thanks Morten! simple_smile Raptier... that's old simple_smile

See the attached dll for the fix. Place the dll in the Taskperformers folder, overwriting the existing tdl interpreter file. (if you're using vista/7, copy it as administrator if you've installed in program files)

Frans Bouma | Lead developer LLBLGen Pro