Skip to content

Commit 1986de2

Browse files
committed
Code cleanup
Cleaned up code and switched on of the Connect calls to use API 2.0.
1 parent b06299b commit 1986de2

File tree

4 files changed

+16
-22
lines changed

4 files changed

+16
-22
lines changed

Storm.xojo_code

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ Protected Module Storm
3131
- Fixed a possible SQL Injection
3232
- Added SerializeJSON Method
3333
- Added DBObject.kUseNilValues Constant to initialize columns with Nil values instead of an empty string
34+
35+
== v1.2.1 == 2025-02-05
36+
- Minor code cleanup.
3437
#tag EndNote
3538

3639
#tag Note, Name = Storm License
37-
Copyright (c) 2014, Paul Lefebvre
40+
Copyright (c) 2014-2025, Paul Lefebvre
3841
All rights reserved.
3942

4043
Redistribution and use in source and binary forms, with or without
@@ -63,7 +66,7 @@ Protected Module Storm
6366
#tag EndNote
6467

6568

66-
#tag Constant, Name = kStormVersion, Type = String, Dynamic = False, Default = \"1.2.0", Scope = Private
69+
#tag Constant, Name = kStormVersion, Type = String, Dynamic = False, Default = \"1.2.1", Scope = Private
6770
#tag EndConstant
6871

6972

Storm.xojo_project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Type=Desktop
2-
RBProjectVersion=2024.011
2+
RBProjectVersion=2024.042
33
MinIDEVersion=20210300
44
OrigIDEVersion=00000000
55
Class=App;App.xojo_code;&h0000000071109B85;&h0000000000000000;false

Storm/DBConnection.xojo_code

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ Protected Class DBConnection
4141
mIsConnected = False
4242
End Try
4343
Else
44-
If mDatabase.Connect Then
44+
Try
45+
mDatabase.Connect
4546
mIsConnected = True
46-
Else
47+
Catch e As DatabaseException
4748
mIsConnected = False
48-
End If
49+
End Try
4950
End If
5051

5152
If mIsConnected Then

Storm/DBObject.xojo_code

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ Protected Class DBObject
176176
Var query As String = "SELECT * FROM " + TableName + " WHERE " + column + " = ?" '+ SqlValue(value)
177177

178178
Var values() as Variant
179-
values.Add value
179+
values.Add(value)
180180

181181
Var row As RowSet
182182
row = mDatabaseConnection.SQLSelect(query, values)
@@ -394,7 +394,6 @@ Protected Class DBObject
394394
Var primaryKeyValue As Int64
395395
Var serverIDValue As String
396396

397-
Var tsNode As XmlNode
398397
For i As Integer = 0 To LastRowIndex
399398

400399
Dim child As JSONItem
@@ -710,14 +709,11 @@ Protected Class DBObject
710709
For Each colName As Variant In mColumn.Keys
711710
If colName <> PrimaryKey Or mPrimaryKeyIsString Or UsePrimaryKeyValue Then
712711
If colName = TimeStamp Then
713-
Values.Add now.SQLDateTime
712+
Values.Add(now.SQLDateTime)
714713
command = command + comma + "?"
715-
'command = command + comma + Now.SQLDateTime.Quote
716714
Else
717-
Values.Add mColumn.Value(colName)
715+
Values.Add(mColumn.Value(colName))
718716
command = command + comma + "?"
719-
720-
'command = command + comma + sqlValue(mColumn.Value(colName))
721717
End If
722718

723719
comma = ","
@@ -732,11 +728,10 @@ Protected Class DBObject
732728
For Each colName As Variant In mColumn.Keys
733729
If colName <> PrimaryKey And colName <> "serverID" Then
734730
If colName = TimeStamp Then
735-
values.Add now.SQLDateTime
731+
values.Add(now.SQLDateTime)
736732
command = command + comma + colName + " = ?"
737-
'command = command + comma + colName + " = " + Now.SQLDateTime.Quote
738733
Else
739-
values.Add mColumn.Value(colName)
734+
values.Add(mColumn.Value(colName))
740735
command = command + comma + colName + " = ?"
741736
End If
742737

@@ -748,8 +743,6 @@ Protected Class DBObject
748743

749744
End If
750745

751-
752-
753746
If mDatabaseConnection.SQLExecute(command, values) Then
754747
mIsDirty = False
755748

@@ -951,17 +944,14 @@ Protected Class DBObject
951944

952945
Var js As new JSONItem
953946

954-
Var children() as JSONItem
955-
956947
Try
957948
For Each o As Storm.DBObject In objects
958-
js.Add o.SerializeJSON()
949+
js.Add(o.SerializeJSON())
959950
Next
960951
Catch e As RuntimeException
961952
MessageBox(e.Message)
962953
End Try
963954

964-
965955
Return js
966956
End Function
967957
#tag EndMethod

0 commit comments

Comments
 (0)