yasser777 / nettiers

Automatically exported from code.google.com/p/nettiers
0 stars 0 forks source link

using columns with function as default values #202

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. I Have a datetime column with default value - getdate()
2. this column is used for tracking changes - but only the database server 
is updating it (on update trigger)
3. so far i have problems using it with nettiers - if the column is not-
nullable, and i don't specify a value on insert, the nettiers insert 
procedure crashes. If i use it as nullable, the nettiers inserts null into 
the column, and so i don't get the default value

What is the expected output? What do you see instead?
i expect to be able to not specify a value for the entity, and after the 
transaction to the db-server (I use SQL-Server), the values will be the 
default values.

What version of .netTiers and CodeSmith are you using?
.netTiers 2.2 and CodeSmith 5.0

Please provide any additional information below.

Original issue reported on code.google.com by geria...@gmail.com on 22 Apr 2009 at 12:54

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 25 May 2009 at 3:30

GoogleCodeExporter commented 9 years ago
Hello,

Is this the same behavior for .netTiers 2.3?

Thanks
-Blake

Original comment by bniemyjski on 25 May 2009 at 4:04

GoogleCodeExporter commented 9 years ago
yes, i'm sorry, i meant 2.3 in the post, i just started using .netTiers at 2.3

Original comment by geria...@gmail.com on 25 May 2009 at 5:47

GoogleCodeExporter commented 9 years ago
Can you create a quick sql script that recreates this issue.

-Blake

Original comment by bniemyjski on 25 May 2009 at 9:37

GoogleCodeExporter commented 9 years ago
it's simple, the template for sql procedures in .netTiers, for insert 
procedure, is 
as follows:
INSERT INTO <%=fqTableName%>
                    (
                    <% for (int i = 0; i < colsUpdatable.Count; 
i++) { %>[<%= colsUpdatable[i].Name %>]<% if (i < colsUpdatable.Count - 1) { %>
                    ,<% } } %>
                    )
                    <% if (colsIdentityRowGuids.Count > 0 && 
IncludeDatabaseFeatures == MoM.Templates.DatabaseType.SQLServer2005) { %>
                        OUTPUT <% for (int i = 0; i < 
colsIdentityRowGuids.Count; i++) {%>INSERTED.<%= colsIdentityRowGuids[i].Name 
%><% if 
(i < colsIdentityRowGuids.Count - 1) { %>,<% } } %> INTO @IdentityRowGuids

                    <%}%>                   
                VALUES
                    (
                    <% for (int i = 0; i < colsUpdatable.Count; 
i++) { %>@<%= GetPropertyName(colsUpdatable[i]) %><% if (i < 
colsUpdatable.Count - 1) 
{ %>
                    ,<% } } %>
                    )
i created a quick fix, in which nullable columns aren't in the normal insert... 
values..., but are added later:
IF NOT @Param IS NULL
UPDATE tableName SET colName = @Param WHERE idColumn = @IdParam

of course it's only after retrieving the new id...
the default values .netTiers does parse from the db should be set in the 
instantiation of the entity.

Original comment by geria...@gmail.com on 26 May 2009 at 7:17

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 26 May 2009 at 1:17

GoogleCodeExporter commented 9 years ago
Hello,

I'm having same issue here, using the version 2.3-r891 (nightly build) that 
mention that an issue with default values in date and time fields have been 
fixed:

(2/17/2011) [Issue 329] – Default values correctly initialised for DateTime & 
Time data types.

This is causing exception when Insert process is performed. How to fix this 
issue, urge!, please.

Thank you

Original comment by cesar.q...@gmail.com on 22 Nov 2012 at 2:24

GoogleCodeExporter commented 9 years ago
Hello,

Never in mind my previous post. I'm missing set the ParseDbColDefaultVal 
property. I think this property must to be checked by default.

Now all working fine. This problem was affecting me long.
Thank you.

Original comment by cesar.q...@gmail.com on 22 Nov 2012 at 3:14