Skip to content

Invalid Method name 'bool' with Postgres t4model generation #1295

Closed
@Kempe

Description

Hi,
just 2 small problems when generating schema with the t4 postgres model:
I'm using linq2db v2.2 and linq2db.PostgreSQL v2.2

1.

The gererated SQLFunctions class uses the BitArray class, but the using statement 'System.Collections' is missing!

2.

the t4 model generator for Postgres generates the following code in the SQLFunctions class when setting
NormalizeNames = true;

[Sql.Function(Name=".bool", ServerSideOnly=true)]
public static bool? **Bool**(int? par451) // this is fine
{
	throw new InvalidOperationException();
}

but if
NormalizeNames = false;
it generates a method name 'bool' -> reserved keyword !

[Sql.Function(Name=".bool", ServerSideOnly=true)]
public static bool? **bool**(int? par451) // this is wrong
{
	throw new InvalidOperationException();
}

Can you please have a look?

Thank you!

Cheers Micha

Activity

Kempe

Kempe commented on Aug 29, 2018

@Kempe
Author

Sorry, but the same happens with 'char' :

[Sql.Function(Name=".char", ServerSideOnly=true)]
public static object char(string par960)
{
	throw new InvalidOperationException();
}
sdanyliv

sdanyliv commented on Aug 29, 2018

@sdanyliv
Member

Yeah there are problems here. But we have workarounds before it is fixed.

  1. Add the following code to your TT file:
Model.Usings.Add("System.Collections"); 
  1. Before generating model, correct procedure name:
Procedures[".char"].Name = "Char";
Kempe

Kempe commented on Aug 29, 2018

@Kempe
Author

Hi sdanyliv, thanks you for help! Your suggest to add 'System.Collections' works fine. But I got an key-not-found exception when renaming the procedure. Is it correct to set 'Procedures[".char"].Name = "Char";' before calling GenerateModel(); ???

Here is my tt file:

NormalizeNames = false;
LoadPostgreSQLMetadata("connection_string");

Model.Usings.Add("System.Collections");
Procedures[".char"].Name = "Char";

GenerateModel();

sdanyliv

sdanyliv commented on Aug 29, 2018

@sdanyliv
Member

@Kempe, sorry i have no idea which name is correct and how it is stored in Procedures Dictionary, try to analyse yourself.

added this to the 2.4.0 milestone on Aug 29, 2018
added a commit that references this issue on Sep 30, 2018
1eec28f
added a commit that references this issue on Oct 2, 2018
dd84805
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Invalid Method name 'bool' with Postgres t4model generation · Issue #1295 · linq2db/linq2db