From: Richard B. <rb...@us...> - 2004-10-07 05:58:32
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20010 Modified Files: CColumnMap.vb CPersistenceBroker.vb CSqlStatement.vb CXMLConfigLoader.vb Log Message: Handle value conversions when using string.empty with columns marked as NOT NULL Index: CPersistenceBroker.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistenceBroker.vb,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** CPersistenceBroker.vb 6 Oct 2004 23:42:24 -0000 1.60 --- CPersistenceBroker.vb 7 Oct 2004 05:57:33 -0000 1.61 *************** *** 1762,1769 **** If Not dt Is Nothing Then For Each myfield In dt.Rows ! Debug.WriteLine(myfield("ColumnName") & " size = " & myfield("ColumnSize").ToString & "; type = " & myfield("DataType").ToString & "; providertype = " & myfield("ProviderType").ToString) cc.Add(myfield("ColumnSize"), myfield("ColumnName")) cc.Add(myfield("DataType"), myfield("ColumnName") & "DT") cc.Add(myfield("ProviderType"), myfield("ColumnName") & "PT") Next End If --- 1762,1774 ---- If Not dt Is Nothing Then For Each myfield In dt.Rows ! If myfield("AllowDBNull") Then ! Debug.WriteLine(myfield("ColumnName") & " (Null) size = " & myfield("ColumnSize").ToString & " type = " & myfield("DataType").ToString & " providertype = " & myfield("ProviderType").ToString) ! Else ! Debug.WriteLine(myfield("ColumnName") & " (Not Null) size = " & myfield("ColumnSize").ToString & " type = " & myfield("DataType").ToString & " providertype = " & myfield("ProviderType").ToString) ! End If cc.Add(myfield("ColumnSize"), myfield("ColumnName")) cc.Add(myfield("DataType"), myfield("ColumnName") & "DT") cc.Add(myfield("ProviderType"), myfield("ColumnName") & "PT") + cc.Add(myfield("AllowDBNull"), myfield("ColumnName") & "NL") Next End If *************** *** 1792,1795 **** --- 1797,1801 ---- AttrMap.ColumnMap.StorageType = cc.Item(AttrMap.ColumnMap.Name & "DT") AttrMap.ColumnMap.ProviderType = cc.Item(AttrMap.ColumnMap.Name & "PT") + AttrMap.ColumnMap.IsNullable = cc.Item(AttrMap.ColumnMap.Name & "NL") Catch Throw New NoColumnException("Error retrieving storage information for column " _ *************** *** 1829,1832 **** --- 1835,1839 ---- AttrMap.ColumnMap.StorageType = cc.Item(AttrMap.ColumnMap.Name & "DT") AttrMap.ColumnMap.ProviderType = cc.Item(AttrMap.ColumnMap.Name & "PT") + AttrMap.ColumnMap.IsNullable = cc.Item(AttrMap.ColumnMap.Name & "NL") Catch Throw New NoColumnException("Error retrieving storage information for column " _ *************** *** 1886,1889 **** --- 1893,1897 ---- colMap.StorageType = cc.Item(ClassMap.SharedTableField & "DT") colMap.ProviderType = cc.Item(ClassMap.SharedTableField & "PT") + colMap.IsNullable = cc.Item(ClassMap.SharedTableField & "NL") Catch Throw New NoColumnException("Error retrieving storage information for column " _ Index: CColumnMap.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CColumnMap.vb,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** CColumnMap.vb 21 Jul 2004 02:55:38 -0000 1.9 --- CColumnMap.vb 7 Oct 2004 05:57:33 -0000 1.10 *************** *** 64,67 **** --- 64,68 ---- Private m_columnType As Type Private m_providerType As Integer + Private m_isNullable As Boolean '''----------------------------------------------------------------------------- *************** *** 223,226 **** --- 224,236 ---- End Property + Public Property IsNullable() As Boolean + Get + Return m_isNullable + End Get + Set(ByVal Value As Boolean) + m_isNullable = Value + End Set + End Property + Public Sub New() MyBase.New() *************** *** 228,231 **** --- 238,242 ---- m_isFindColumn = False m_isIdentityColumn = False + m_isNullable = True End Sub Index: CSqlStatement.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CSqlStatement.vb,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** CSqlStatement.vb 1 Sep 2004 04:21:12 -0000 1.9 --- CSqlStatement.vb 7 Oct 2004 05:57:33 -0000 1.10 *************** *** 125,144 **** sp.Value = obj ! If IsNullAlias(obj) Then ! sp.Value = DBNull.Value ! Else ! If TypeOf (obj) Is Date Or TypeOf (obj) Is DateTime Then ! dd = CType(obj, DateTime) ! If dd = Date.MinValue Then ! sp.Value = DBNull.Value ! End If ! End If ! End If ! If sp.Value Is DBNull.Value Then ! Debug.WriteLine(sp.Name & ": NULL") ! Else ! Debug.WriteLine(sp.Name & ": " & sp.Value.ToString) ! End If ! m_paramValues.Add(sp) End Sub End Class --- 125,155 ---- sp.Value = obj ! If c.IsNullable Then ! If IsNullAlias(obj) Then ! sp.Value = DBNull.Value ! Else ! If TypeOf (obj) Is Date Or TypeOf (obj) Is DateTime Then ! dd = CType(obj, DateTime) ! If dd = Date.MinValue Then ! sp.Value = DBNull.Value ! End If ! End If ! End If ! End If ! If sp.Value Is DBNull.Value Then ! Debug.WriteLine(sp.Name & ": NULL") ! Else ! If sp.Value Is Nothing Then ! If c.StorageType Is GetType(String) Then ! sp.Value = String.Empty ! ElseIf c.StorageType Is GetType(Integer) Then ! sp.Value = 0 ! Else ! Throw New AttributeValueException("Tried to pass nothing to a column that does not allow NULLs") ! End If ! End If ! Debug.WriteLine(sp.Name & ": " & sp.Value.ToString) ! End If ! m_paramValues.Add(sp) End Sub End Class Index: CXMLConfigLoader.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CXMLConfigLoader.vb,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** CXMLConfigLoader.vb 28 Sep 2004 04:19:04 -0000 1.22 --- CXMLConfigLoader.vb 7 Oct 2004 05:57:33 -0000 1.23 *************** *** 367,374 **** For Each myfield In dt.Rows 'For each field in the table get the column info for later use ! Debug.WriteLine(myfield("ColumnName") & " size = " & myfield("ColumnSize").ToString & " type = " & myfield("DataType").ToString & " providertype = " & myfield("ProviderType").ToString) cc.Add(myfield("ColumnSize"), myfield("ColumnName")) cc.Add(myfield("DataType"), myfield("ColumnName") & "DT") cc.Add(myfield("ProviderType"), myfield("ColumnName") & "PT") Next End If --- 367,379 ---- For Each myfield In dt.Rows 'For each field in the table get the column info for later use ! If myfield("AllowDBNull") Then ! Debug.WriteLine(myfield("ColumnName") & " (Null) size = " & myfield("ColumnSize").ToString & " type = " & myfield("DataType").ToString & " providertype = " & myfield("ProviderType").ToString) ! Else ! Debug.WriteLine(myfield("ColumnName") & " (Not Null) size = " & myfield("ColumnSize").ToString & " type = " & myfield("DataType").ToString & " providertype = " & myfield("ProviderType").ToString) ! End If cc.Add(myfield("ColumnSize"), myfield("ColumnName")) cc.Add(myfield("DataType"), myfield("ColumnName") & "DT") cc.Add(myfield("ProviderType"), myfield("ColumnName") & "PT") + cc.Add(myfield("AllowDBNull"), myfield("ColumnName") & "NL") Next End If *************** *** 376,384 **** If Not ClassMap.SharedTableField Is Nothing Then 'Create a column map for the sharedtablefield ! Dim colMap = New CColumnMap Try colMap.StorageSize = cc.Item(ClassMap.SharedTableField) colMap.StorageType = cc.Item(ClassMap.SharedTableField & "DT") colMap.ProviderType = cc.Item(ClassMap.SharedTableField & "PT") Catch Throw New NoColumnException("Error retrieving storage information for column " _ --- 381,390 ---- If Not ClassMap.SharedTableField Is Nothing Then 'Create a column map for the sharedtablefield ! Dim colMap As CColumnMap = New CColumnMap Try colMap.StorageSize = cc.Item(ClassMap.SharedTableField) colMap.StorageType = cc.Item(ClassMap.SharedTableField & "DT") colMap.ProviderType = cc.Item(ClassMap.SharedTableField & "PT") + colMap.IsNullable = cc.Item(ClassMap.SharedTableField & "NL") Catch Throw New NoColumnException("Error retrieving storage information for column " _ *************** *** 401,404 **** --- 407,411 ---- AttrMap.ColumnMap.StorageType = cc.Item(AttrMap.ColumnMap.Name & "DT") AttrMap.ColumnMap.ProviderType = cc.Item(AttrMap.ColumnMap.Name & "PT") + AttrMap.ColumnMap.IsNullable = cc.Item(AttrMap.ColumnMap.Name & "NL") Catch Throw New XMLMappingException("Error retrieving database information for column " _ |