Skip to content

NH-3749 - Unnecessary comma in CREATE TABLE statement #1037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nhibernate-bot opened this issue Oct 12, 2017 · 0 comments
Closed

NH-3749 - Unnecessary comma in CREATE TABLE statement #1037

nhibernate-bot opened this issue Oct 12, 2017 · 0 comments

Comments

@nhibernate-bot
Copy link
Collaborator

nhibernate-bot commented Oct 12, 2017

Alexey Lesnyh created an issue — 20th January 2015, 13:25:42:

I develop NHibernate Driver for DBMS Linter SQL and found a problem in file Nhibernate\Mapping\Table.cs. The problem is in the following code:

foreach (UniqueKey uk in UniqueKeyIterator) 
{ 
	buf.Append(',').Append(uk.SqlConstraintString(dialect)); 
}

This code produces unnecessary comma in CREATE TABLE statement if dialect doesn't support not null unique constraints. For example, in test Nhibernate.Test.Component.Basic.ComponentWithUniqueConstraintTests.CanBePersistedWithUniqueValues we have the following query:

create table Employee (Id BIGINT not null, Name VARCHAR(255) null, Dob DATE null, HireDate DATE null, primary key (Id),); 

I suggest that we check property dialect.SupportsNotNullUnique before running foreach loop. Something like this:

if (dialect.SupportsNotNullUnique)
{
	foreach (UniqueKey uk in UniqueKeyIterator)
	{
		buf.Append(',').Append(uk.SqlConstraintString(dialect));
	}
}

Ricardo Peres added a comment — 20th January 2015, 13:36:30:

Can you submit a pull request with your solution and a unit test? It makes it easier to test and integrate.


Alexey Lesnyh added a comment — 20th January 2015, 13:37:09:

I've created a pull request:
#393

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants