SQLMetal capitalization issues

199 views
Skip to first unread message

Andrus Moor

unread,
Mar 14, 2008, 2:36:38 PM3/14/08
to dbl...@googlegroups.com
I tried todays sqlmetal from svn. I have non-english column and table names,
some hundres of tables and thousands of columns.
d notized:

1. Entity type names after first letter are capitalized randomly: some
random characters inside name are in upper case.

How to force previous behaviour so that only first character is capitalized
and xml file can be used for exceptions ?

2. All property names are lowercace.

How to force previous behaviour so that first letter of property name is in
uppercase and fieldrenames.xml can be used for exceptions ?

3. Fields names contain randomly capitalized characters.


Andrus.


my sqlmetal.exe.config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

<configSections>
<section name="parameters"
type="System.Configuration.AppSettingsSection" />
<section name="providers" type="SqlMetal.ProvidersSection, SqlMetal" />
</configSections>

<appSettings>
</appSettings>

<parameters>
<add key="forceUcaseTableName" value="True"/>
<add key="forceUcaseFieldName" value="True"/>

<add key="user" value="admin"/>
<add key="database" value="mydb"/>
<add key="server" value="localhost"/>

<add key="verboseForeignKeys" value="true"/>
<add key="namespace" value="MyApp.Entity"/>
<add key="renamesFile" value="MyFieldRenames.xml"/>
<add key="forceUcaseID" value="false"/>
<add key="useDomainTypes" value="false"/>
<add key="readLineAtExit" value="true"/>

<add key="EntityInterfaces"
value="MyApp.Business.EntityBase,INotifyPropertyChanging,INotifyPropertyChanged"/>


<!-- picrap: don't know what it is

<add key="ns" value="LinqMysql.user"/>
-->
</parameters>

<providers>
<providers>
<provider name="MySql"
dbLinqSchemaLoader="DbLinq.MySql.MySqlSchemaLoader, DbLinq.MySql"
databaseConnection="MySql.Data.MySqlClient.MySqlConnection,
MySql.Data" />

<provider name="Oracle"
dbLinqSchemaLoader="DbLinq.Oracle.OracleSchemaLoader, DbLinq.Oracle"
databaseConnection="System.Data.OracleClient.OracleConnection,
System.Data.OracleClient" />

<provider name="OracleODP"
dbLinqSchemaLoader="DbLinq.Oracle.OracleSchemaLoader, DbLinq.Oracle"
databaseConnection="Oracle.DataAccess.Client.OracleConnection,
Oracle.DataAccess" />

<provider name="PostgreSql"
dbLinqSchemaLoader="DbLinq.PostgreSql.PgsqlSchemaLoader, DbLinq.PostgreSql"
databaseConnection="Npgsql.NpgsqlConnection,
Npgsql" />

<provider name="Sqlite"
dbLinqSchemaLoader="DbLinq.Sqlite.SqliteSchemaLoader, DbLinq.Sqlite"
databaseConnection="System.Data.SQLite.SQLiteConnection,
System.Data.SQLite" />
</providers>
</providers>

</configuration>

gmo...@gmail.com

unread,
Mar 14, 2008, 4:54:52 PM3/14/08
to DbLinq
Hi Andrus,
could you provide a small dbml file that reproduces the issue?
I can take a look at it in about 10 days.

picrap

unread,
Mar 15, 2008, 6:30:55 AM3/15/08
to DbLinq
Hi Andrus,

since I'm the guilty guy who changed SqlMetal behavior, I'm going to
take a look at it. As usual, could you make a post on the bugtracker?
I'll take a look at it soon.

Andrus Moor

unread,
Mar 15, 2008, 2:28:18 PM3/15/08
to dbl...@googlegroups.com, gmo...@gmail.com
George,

> could you provide a small dbml file that reproduces the issue?
> I can take a look at it in about 10 days.

dbml file attached.
I cc:d to you directly also since not sure how this group treats
attachments. Note random capitalization of table names.

Also trying to create code or schema from Northwind db does not work:

D:\dblinq\SqlMetal\bin>SQLMetal.exe -Dbml=northwind.dbml -Provider=PostgreSql
-
user:admin -database:Northwind -server:localhost -password:linq2
No tables found for schema Northwind, exiting
SqlMetal failed:System.NullReferenceException: Object reference not set to
an in
stance of an object.
at DbLinq.Schema.DbmlSerializer.Write(Stream xmlStream, Database dbml) in
D:\
dblinq\DbLinq\Schema\DbmlSerializer.cs:line 102
at SqlMetal.Program.Main(String[] args) in
D:\dblinq\SqlMetal\Program.cs:line
80

Other notes:

1. Can anybody review/commit my last patch posted in this list or give my
non-gmail address commit rights.
2. Partial property update test WriteTest().G9_UpdateOnlyChangedProperty()
still fails.

Andrus.

eeva.zip

picrap

unread,
Mar 16, 2008, 4:39:20 AM3/16/08
to DbLinq
Apparently Google code does not allow non gmail accounts, but where is
the problem with your gmail account?
>  eeva.zip
> 72KTélécharger

Andrus Moor

unread,
Mar 18, 2008, 3:29:37 PM3/18/08
to dbl...@googlegroups.com
Pascal,

> since I'm the guilty guy who changed SqlMetal behavior, I'm going to
> take a look at it. As usual, could you make a post on the bugtracker?
> I'll take a look at it soon.

Done.

http://code.google.com/p/dblinq2007/issues/detail?id=48

Andrus.

To reproduce:

1. Run sqlmetal against nortwind database:

SQLMetal.exe -Provider=PostgreSql -forceUcaseID=false -forceUcaseFieldName -forceUcaseTableName
-verboseForeignKeys -user:postgres -database:northwind -server:localhost -password:xxxxx

2. Look into northwind.cs file.

Expected output:

Only first character in property and table names should be capitalized.

Observed:

1. English language word list is used for captialization. It it not possible
to turn this off.

2. Some characters in some names are randomly capitalized:

[Column(Storage = "hiredAte", ...
HiredAte
QuantityPeruNit
UnitsInsToCK
[Association(Storage = "fKTeRrRegion",
fKProdCatG

3. pgsqlfieldranames.xml content is ignored during processing.

picrap

unread,
Mar 18, 2008, 7:01:26 PM3/18/08
to DbLinq
Hi Andrus,

I just placed a new experimental version of the capitalization
algorithm on the SVN repository:
- When casing is present in names, it is not changed. It is guessed
when names look case insensitive (this is why I asked a lot of
questions for all databases).
- The /pluralize parameter (off by default) now works and set names to
singular/plural only if specified.
So you should have a correct casing now. However, it's just for
MySQL... I'll make the changes for other databases in the next few
days.

Pascal.

picrap

unread,
Mar 18, 2008, 7:17:00 PM3/18/08
to DbLinq
And I forgot to say that table aliases are also used again (however I
didn't check this at all)...

Andrus Moor

unread,
Mar 19, 2008, 7:47:28 AM3/19/08
to dbl...@googlegroups.com
Pascal,

>I just placed a new experimental version of the capitalization
> algorithm on the SVN repository:

Thak you.
I tried todays version. I noticed
that -forceUcaseID=false -forceUcaseFieldName -forceUcaseTableName
parameters are not accepted anymore.
I need the following rules for PostgreSQL. They worked in earlier version
but not in todays version:

1. Make only first letter in every table and property name in upper case.
All other characters must be in lower case.
2. Use pluralization/singularizaton.
3. Allow to specify exceptions for the rules above in xml file.

Any idea how to get this result ?

Andrus.

Andrus Moor

unread,
Mar 19, 2008, 7:54:51 AM3/19/08
to dbl...@googlegroups.com
> And I forgot to say that table aliases are also used again (however I
didn't check this at all)...

This is not critical issue since we can use find/replace in text editor to
fix.
However it would be nice to eliminate the need to use Find/Replace.

Andrus.

Andrus Moor

unread,
Mar 19, 2008, 9:52:01 AM3/19/08
to dbl...@googlegroups.com
>Apparently Google code does not allow non gmail accounts,

from

http://code.google.com/p/support/wiki/WhatsNew

Sept 2007
Project owners and members can now be specified with the full email address
of any Google Account.

Can I use my email kobruleht2 at hot point ee

> but where is the problem with your gmail account?

I don'nt have it.
I created it now if previous email still fails.

kobruleht2 at gmail dot com

Andrus.

picrap

unread,
Mar 19, 2008, 10:01:40 AM3/19/08
to DbLinq
The common new behavior on SqlMetal has to be the following (we'll try
to stick to it as much as possible...):
- The casing is not limited to the one you specify (PascalCase). It is
the standard for public properties, however private fields use a
camelCase.
- The schema extractors (ISchemaLoader) determine if a provided name
is case sensitive (== its casing is valid, so we keep it) or not (in
this case, we try to figure it out using an english dictionary... We
may also extend dictionaries).
- A dictionary can be used to specify an alternative name (casing
included) for tables
So, in a very concrete way:
1. Make only first letter in every table and property name in upper
case. All other characters must be in lower case.
--> This is the default behavior, PascalCase, if the table name
does not specify a case
2. Use pluralization/singularizaton.
--> /pluralize now works
3. Allow to specify exceptions for the rules above in xml file.
--> the dictionary works again and no further processing is done
if a name is found in the dictionary. Please note that I didn't test
this case.

Andrus Moor

unread,
Mar 19, 2008, 11:33:32 AM3/19/08
to dbl...@googlegroups.com
> So, in a very concrete way:
> 1. Make only first letter in every table and property name in upper
> case. All other characters must be in lower case.
> --> This is the default behavior, PascalCase, if the table name
> does not specify a case

English dictionary usage makes incorrect results. Eq. in nortwhind, it
generates HiredAte while correct it HireDate.
If there are large number of names or schema is not known it is difficult to
add all names to xml file.
It is not reasonable to create case-sensitive names in database: sql is case
insensitive language.

How to specify other language file or disable english dictionary usage so
that
only first letter is
capitalized always ?

> 2. Use pluralization/singularizaton.
> --> /pluralize now works

I created cs files with and without -pluralize switch

Result code is exactly the same.

> 3. Allow to specify exceptions for the rules above in xml file.
> --> the dictionary works again and no further processing is done
> if a name is found in the dictionary. Please note that I didn't test
> this case.

I added line to config file:

<add key="renamesFile" value="pgsqlFieldRenames.xml"/>

sqlmetal shows : Loading renames file: PgsqlFieldRenames.xml

HireDate still appears as HiredAte in generated cs file.

Andrus.

Pascal Craponne

unread,
Mar 19, 2008, 12:06:29 PM3/19/08
to dbl...@googlegroups.com
All of this works only in MySQL at the moment... Well, that's what I hope :)
Reply all
Reply to author
Forward
0 new messages