peasys-ruby 1.0.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/active_record/connection_adapters/peasys/column.rb +20 -0
- data/lib/active_record/connection_adapters/peasys/database_statements.rb +209 -0
- data/lib/active_record/connection_adapters/peasys/quoting.rb +99 -0
- data/lib/active_record/connection_adapters/peasys/schema_creation.rb +27 -0
- data/lib/active_record/connection_adapters/peasys/schema_definitions.rb +10 -0
- data/lib/active_record/connection_adapters/peasys/schema_dumper.rb +88 -0
- data/lib/active_record/connection_adapters/peasys/schema_statements.rb +431 -0
- data/lib/active_record/connection_adapters/peasys_adapter.rb +207 -0
- data/lib/arel/visitors/peasys.rb +53 -0
- data/lib/pea_client.rb +481 -477
- data/lib/pea_exception.rb +30 -30
- data/lib/pea_response.rb +299 -299
- data/lib/peasys-ruby.rb +11 -0
- metadata +67 -8
data/lib/pea_exception.rb
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
class PeaError < StandardError
|
|
3
|
-
|
|
4
|
-
##
|
|
5
|
-
# Abstract the concept of exception encountered during the manipulation of the Peasys library
|
|
6
|
-
#
|
|
7
|
-
# Params:
|
|
8
|
-
# +msg+:: The message describing the error.
|
|
9
|
-
|
|
10
|
-
def initialize(msg="Error coming from the Peasys library")
|
|
11
|
-
super(msg)
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
class PeaConnexionError < PeaError
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
class PeaInvalidCredentialsError < PeaConnexionError
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
class PeaInvalidLicenseKeyError < PeaConnexionError
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
class PeaQueryerror < PeaError
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
class PeaInvalidSyntaxQueryError < PeaQueryerror
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
class PeaUnsupportedOperationError < PeaQueryerror
|
|
1
|
+
|
|
2
|
+
class PeaError < StandardError
|
|
3
|
+
|
|
4
|
+
##
|
|
5
|
+
# Abstract the concept of exception encountered during the manipulation of the Peasys library
|
|
6
|
+
#
|
|
7
|
+
# Params:
|
|
8
|
+
# +msg+:: The message describing the error.
|
|
9
|
+
|
|
10
|
+
def initialize(msg="Error coming from the Peasys library")
|
|
11
|
+
super(msg)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class PeaConnexionError < PeaError
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class PeaInvalidCredentialsError < PeaConnexionError
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class PeaInvalidLicenseKeyError < PeaConnexionError
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class PeaQueryerror < PeaError
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
class PeaInvalidSyntaxQueryError < PeaQueryerror
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class PeaUnsupportedOperationError < PeaQueryerror
|
|
31
31
|
end
|
data/lib/pea_response.rb
CHANGED
|
@@ -1,300 +1,300 @@
|
|
|
1
|
-
# Abstracts the concept of response in the case of a query executed on the database of an AS/400 server by a PeaClient object.
|
|
2
|
-
|
|
3
|
-
class PeaResponse
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
# Initialize a new instance of the PeaResponse class.
|
|
7
|
-
#
|
|
8
|
-
# Params:
|
|
9
|
-
# +has_succeeded+:: Boolean set to true if the query has correctly been executed. Set to true if the SQL state is 00000.
|
|
10
|
-
# +sql_message+:: SQL message return from the execution of the query.
|
|
11
|
-
# +sql_state+:: SQL state return from the execution of the query.
|
|
12
|
-
|
|
13
|
-
def initialize(has_succeeded, sql_message, sql_state)
|
|
14
|
-
@has_succeeded = has_succeeded
|
|
15
|
-
@sql_message = sql_message
|
|
16
|
-
@sql_state = sql_state
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def has_succeeded
|
|
20
|
-
@has_succeeded
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def sql_message
|
|
24
|
-
@sql_message
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def sql_state
|
|
28
|
-
@sql_state
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# Represents the concept of response in the case of a CREATE query executed on the database of an AS/400 server by a PeaClient object.
|
|
33
|
-
|
|
34
|
-
class PeaCreateResponse < PeaResponse
|
|
35
|
-
|
|
36
|
-
##
|
|
37
|
-
# Initialize a new instance of the PeaCreateResponse class.
|
|
38
|
-
#
|
|
39
|
-
# Params:
|
|
40
|
-
# +has_succeeded+:: Boolean set to true if the query has correctly been executed. Set to true if the SQL state is 00000.
|
|
41
|
-
# +sql_message+:: SQL message return from the execution of the query.
|
|
42
|
-
# +sql_state+:: SQL state return from the execution of the query.
|
|
43
|
-
# +database_name+:: Name of the database if the SQL create query creates a new database.
|
|
44
|
-
# +index_name+:: Name of the index if the SQL create query creates a new index.
|
|
45
|
-
# +table_schema+:: Schema of the table if the SQL create query creates a new table. The Schema is a Dictionary with columns' name as key and a ColumnInfo object as value.
|
|
46
|
-
|
|
47
|
-
def initialize(has_succeeded, sql_message, sql_state, database_name, index_name, table_schema)
|
|
48
|
-
super has_succeeded, sql_message, sql_state
|
|
49
|
-
|
|
50
|
-
@database_name = database_name
|
|
51
|
-
@index_name = index_name
|
|
52
|
-
@table_schema = table_schema
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def database_name
|
|
56
|
-
@database_name
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def index_name
|
|
60
|
-
@index_name
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def table_schema
|
|
64
|
-
@table_schema
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
# Represents the concept of response in the case of an ALTER query executed on the database of an AS/400 server by a PeaClient object.
|
|
69
|
-
|
|
70
|
-
class PeaAlterResponse < PeaResponse
|
|
71
|
-
|
|
72
|
-
##
|
|
73
|
-
# Initialize a new instance of the PeaAlterResponse class.
|
|
74
|
-
#
|
|
75
|
-
# Params:
|
|
76
|
-
# +has_succeeded+:: Boolean set to true if the query has correctly been executed. Set to true if the SQL state is 00000.
|
|
77
|
-
# +sql_message+:: SQL message return from the execution of the query.
|
|
78
|
-
# +sql_state+:: SQL state return from the execution of the query.
|
|
79
|
-
# +table_schema+:: Schema of the table if the SQL create query creates a new table. The Schema is a Dictionary with columns' name as key and a ColumnInfo object as value.
|
|
80
|
-
|
|
81
|
-
def initialize(has_succeeded, sql_message, sql_state, table_schema)
|
|
82
|
-
super has_succeeded, sql_message, sql_state
|
|
83
|
-
|
|
84
|
-
@table_schema = table_schema
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def table_schema
|
|
88
|
-
@table_schema
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
# Represents the concept of response in the case of a DROP query executed on the database of an AS/400 server by a PeaClient object.
|
|
93
|
-
|
|
94
|
-
class PeaDropResponse < PeaResponse
|
|
95
|
-
|
|
96
|
-
##
|
|
97
|
-
# Initialize a new instance of the PeaDropResponse class.
|
|
98
|
-
#
|
|
99
|
-
# Params:
|
|
100
|
-
# +has_succeeded+:: Boolean set to true if the query has correctly been executed. Set to true if the SQL state is 00000.
|
|
101
|
-
# +sql_message+:: SQL message return from the execution of the query.
|
|
102
|
-
# +sql_state+:: SQL state return from the execution of the query.
|
|
103
|
-
|
|
104
|
-
def initialize(has_succeeded, sql_message, sql_state)
|
|
105
|
-
super has_succeeded, sql_message, sql_state
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
# Represents the concept of response in the case of a SELECT query executed on the database of an AS/400 server by a PeaClient object.
|
|
110
|
-
|
|
111
|
-
class PeaSelectResponse < PeaResponse
|
|
112
|
-
|
|
113
|
-
##
|
|
114
|
-
# Initialize a new instance of the PeaSelectResponse class.
|
|
115
|
-
#
|
|
116
|
-
# Params:
|
|
117
|
-
# +has_succeeded+:: Boolean set to true if the query has correctly been executed. Set to true if the SQL state is 00000.
|
|
118
|
-
# +sql_message+:: SQL message return from the execution of the query.
|
|
119
|
-
# +sql_state+:: SQL state return from the execution of the query.
|
|
120
|
-
# +result+:: Results of the query in the form of an Dictionary where the columns' name are the key and the values are the elements of this column in the SQL table.
|
|
121
|
-
# +row_count+:: Represents the number of rows that have been retreived by the query.
|
|
122
|
-
# +columns_name+:: Array representing the name of the columns in the order of the SELECT query.
|
|
123
|
-
|
|
124
|
-
def initialize(has_succeeded, sql_message, sql_state, result, row_count, columns_name)
|
|
125
|
-
super has_succeeded, sql_message, sql_state
|
|
126
|
-
|
|
127
|
-
@result = result
|
|
128
|
-
@row_count = row_count
|
|
129
|
-
@columns_name = columns_name
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
def result
|
|
133
|
-
@result
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
def row_count
|
|
137
|
-
@row_count
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
def columns_name
|
|
141
|
-
@columns_name
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
# Represents the concept of response in the case of an UPDATE query executed on the database of an AS/400 server by a PeaClient object.
|
|
146
|
-
|
|
147
|
-
class PeaUpdateResponse < PeaResponse
|
|
148
|
-
|
|
149
|
-
##
|
|
150
|
-
# Initialize a new instance of the PeaResponse class.
|
|
151
|
-
#
|
|
152
|
-
# Params:
|
|
153
|
-
# +has_succeeded+:: Boolean set to true if the query has correctly been executed. Set to true if the SQL state is 00000.
|
|
154
|
-
# +sql_message+:: SQL message return from the execution of the query.
|
|
155
|
-
# +sql_state+:: SQL state return from the execution of the query.
|
|
156
|
-
# +row_count+:: Represents the number of rows that have been updated by the query.
|
|
157
|
-
|
|
158
|
-
def initialize(has_succeeded, sql_message, sql_state, row_count)
|
|
159
|
-
super has_succeeded, sql_message, sql_state
|
|
160
|
-
|
|
161
|
-
@row_count = row_count
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
def row_count
|
|
165
|
-
@row_count
|
|
166
|
-
end
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
# Represents the concept of response in the case of a DELETE query executed on the database of an AS/400 server by a PeaClient object.
|
|
170
|
-
|
|
171
|
-
class PeaDeleteResponse < PeaResponse
|
|
172
|
-
|
|
173
|
-
##
|
|
174
|
-
# Initialize a new instance of the PeaResponse class.
|
|
175
|
-
#
|
|
176
|
-
# Params:
|
|
177
|
-
# +has_succeeded+:: Boolean set to true if the query has correctly been executed. Set to true if the SQL state is 00000.
|
|
178
|
-
# +sql_message+:: SQL message return from the execution of the query.
|
|
179
|
-
# +sql_state+:: SQL state return from the execution of the query.
|
|
180
|
-
# +row_count+:: Represents the number of rows that have been updated by the query.
|
|
181
|
-
|
|
182
|
-
def initialize(has_succeeded, sql_message, sql_state, row_count)
|
|
183
|
-
super has_succeeded, sql_message, sql_state
|
|
184
|
-
|
|
185
|
-
@row_count = row_count
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
def row_count
|
|
189
|
-
@row_count
|
|
190
|
-
end
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
# Represents the concept of response in the case of an INSERT query executed on the database of an AS/400 server by a PeaClient object.
|
|
194
|
-
|
|
195
|
-
class PeaInsertResponse < PeaResponse
|
|
196
|
-
|
|
197
|
-
##
|
|
198
|
-
# Initialize a new instance of the PeaResponse class.
|
|
199
|
-
#
|
|
200
|
-
# Params:
|
|
201
|
-
# +has_succeeded+:: Boolean set to true if the query has correctly been executed. Set to true if the SQL state is 00000.
|
|
202
|
-
# +sql_message+:: SQL message return from the execution of the query.
|
|
203
|
-
# +sql_state+:: SQL state return from the execution of the query.
|
|
204
|
-
# +row_count+:: Represents the number of rows that have been updated by the query.
|
|
205
|
-
|
|
206
|
-
def initialize(has_succeeded, sql_message, sql_state, row_count)
|
|
207
|
-
super has_succeeded, sql_message, sql_state
|
|
208
|
-
|
|
209
|
-
@row_count = row_count
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
def row_count
|
|
213
|
-
@row_count
|
|
214
|
-
end
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
# Represents the concept of response in the case of an OS/400 command executed on the database of an AS/400 server by a PeaClient object.
|
|
218
|
-
|
|
219
|
-
class PeaCommandResponse
|
|
220
|
-
|
|
221
|
-
##
|
|
222
|
-
# Initialize a new instance of the PeaCommandResponse class.
|
|
223
|
-
#
|
|
224
|
-
# Params:
|
|
225
|
-
# +has_succeeded+:: Boolean set to true if the command has correctly been executed meaning that no CPFxxxx was return. Still, description messages can be return along with CP*xxxx.
|
|
226
|
-
# +warnings+:: List of warnings that results form the command execution. Errors are of the form : CP*xxxx Description of the warning.
|
|
227
|
-
|
|
228
|
-
def initialize(warnings)
|
|
229
|
-
@warnings = warnings
|
|
230
|
-
end
|
|
231
|
-
|
|
232
|
-
def warnings
|
|
233
|
-
@warnings
|
|
234
|
-
end
|
|
235
|
-
end
|
|
236
|
-
|
|
237
|
-
# Represents the concept of metadata for a column of an SQL table on the AS/400 server.
|
|
238
|
-
class ColumnInfo
|
|
239
|
-
|
|
240
|
-
##
|
|
241
|
-
# Initialize a new instance of the ColumnInfo class.
|
|
242
|
-
#
|
|
243
|
-
# Params:
|
|
244
|
-
# +column_name+:: Name of the column.
|
|
245
|
-
# +ordinal_position+:: Ordinal position of the column.
|
|
246
|
-
# +data_type+:: DB2 Type of the data contain in the column.
|
|
247
|
-
# +length+:: Length of the data contain in the column.
|
|
248
|
-
# +numeric_scale+:: Scale of the data contain in the column if numeric type.
|
|
249
|
-
# +is_nullable+:: Y/N depending on the nullability of the field.
|
|
250
|
-
# +is_updatable+:: Y/N depending on the updaptability of the field.
|
|
251
|
-
# +numeric_precision+:: Precision of the data contain in the column if numeric type.
|
|
252
|
-
|
|
253
|
-
def initialize(column_name, ordinal_position, data_type, length, numeric_scale, is_nullable, is_updatable, numeric_precision)
|
|
254
|
-
@column_name = column_name
|
|
255
|
-
@ordinal_position = ordinal_position
|
|
256
|
-
@data_type = data_type
|
|
257
|
-
@length = length
|
|
258
|
-
@numeric_scale = numeric_scale
|
|
259
|
-
@numeric_precision = numeric_precision
|
|
260
|
-
@is_nullable = is_nullable
|
|
261
|
-
@is_updatable = is_updatable
|
|
262
|
-
@numeric_precision = numeric_precision
|
|
263
|
-
end
|
|
264
|
-
|
|
265
|
-
def column_name
|
|
266
|
-
@column_name
|
|
267
|
-
end
|
|
268
|
-
|
|
269
|
-
def ordinal_position
|
|
270
|
-
@ordinal_position
|
|
271
|
-
end
|
|
272
|
-
|
|
273
|
-
def data_type
|
|
274
|
-
@data_type
|
|
275
|
-
end
|
|
276
|
-
|
|
277
|
-
def length
|
|
278
|
-
@length
|
|
279
|
-
end
|
|
280
|
-
|
|
281
|
-
def numeric_scale
|
|
282
|
-
@numeric_scale
|
|
283
|
-
end
|
|
284
|
-
|
|
285
|
-
def numeric_precision
|
|
286
|
-
@numeric_precision
|
|
287
|
-
end
|
|
288
|
-
|
|
289
|
-
def is_nullable
|
|
290
|
-
@is_nullable
|
|
291
|
-
end
|
|
292
|
-
|
|
293
|
-
def is_updatable
|
|
294
|
-
@is_updatable
|
|
295
|
-
end
|
|
296
|
-
|
|
297
|
-
def numeric_precision
|
|
298
|
-
@numeric_precision
|
|
299
|
-
end
|
|
1
|
+
# Abstracts the concept of response in the case of a query executed on the database of an AS/400 server by a PeaClient object.
|
|
2
|
+
|
|
3
|
+
class PeaResponse
|
|
4
|
+
|
|
5
|
+
##
|
|
6
|
+
# Initialize a new instance of the PeaResponse class.
|
|
7
|
+
#
|
|
8
|
+
# Params:
|
|
9
|
+
# +has_succeeded+:: Boolean set to true if the query has correctly been executed. Set to true if the SQL state is 00000.
|
|
10
|
+
# +sql_message+:: SQL message return from the execution of the query.
|
|
11
|
+
# +sql_state+:: SQL state return from the execution of the query.
|
|
12
|
+
|
|
13
|
+
def initialize(has_succeeded, sql_message, sql_state)
|
|
14
|
+
@has_succeeded = has_succeeded
|
|
15
|
+
@sql_message = sql_message
|
|
16
|
+
@sql_state = sql_state
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def has_succeeded
|
|
20
|
+
@has_succeeded
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def sql_message
|
|
24
|
+
@sql_message
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def sql_state
|
|
28
|
+
@sql_state
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Represents the concept of response in the case of a CREATE query executed on the database of an AS/400 server by a PeaClient object.
|
|
33
|
+
|
|
34
|
+
class PeaCreateResponse < PeaResponse
|
|
35
|
+
|
|
36
|
+
##
|
|
37
|
+
# Initialize a new instance of the PeaCreateResponse class.
|
|
38
|
+
#
|
|
39
|
+
# Params:
|
|
40
|
+
# +has_succeeded+:: Boolean set to true if the query has correctly been executed. Set to true if the SQL state is 00000.
|
|
41
|
+
# +sql_message+:: SQL message return from the execution of the query.
|
|
42
|
+
# +sql_state+:: SQL state return from the execution of the query.
|
|
43
|
+
# +database_name+:: Name of the database if the SQL create query creates a new database.
|
|
44
|
+
# +index_name+:: Name of the index if the SQL create query creates a new index.
|
|
45
|
+
# +table_schema+:: Schema of the table if the SQL create query creates a new table. The Schema is a Dictionary with columns' name as key and a ColumnInfo object as value.
|
|
46
|
+
|
|
47
|
+
def initialize(has_succeeded, sql_message, sql_state, database_name, index_name, table_schema)
|
|
48
|
+
super has_succeeded, sql_message, sql_state
|
|
49
|
+
|
|
50
|
+
@database_name = database_name
|
|
51
|
+
@index_name = index_name
|
|
52
|
+
@table_schema = table_schema
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def database_name
|
|
56
|
+
@database_name
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def index_name
|
|
60
|
+
@index_name
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def table_schema
|
|
64
|
+
@table_schema
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Represents the concept of response in the case of an ALTER query executed on the database of an AS/400 server by a PeaClient object.
|
|
69
|
+
|
|
70
|
+
class PeaAlterResponse < PeaResponse
|
|
71
|
+
|
|
72
|
+
##
|
|
73
|
+
# Initialize a new instance of the PeaAlterResponse class.
|
|
74
|
+
#
|
|
75
|
+
# Params:
|
|
76
|
+
# +has_succeeded+:: Boolean set to true if the query has correctly been executed. Set to true if the SQL state is 00000.
|
|
77
|
+
# +sql_message+:: SQL message return from the execution of the query.
|
|
78
|
+
# +sql_state+:: SQL state return from the execution of the query.
|
|
79
|
+
# +table_schema+:: Schema of the table if the SQL create query creates a new table. The Schema is a Dictionary with columns' name as key and a ColumnInfo object as value.
|
|
80
|
+
|
|
81
|
+
def initialize(has_succeeded, sql_message, sql_state, table_schema)
|
|
82
|
+
super has_succeeded, sql_message, sql_state
|
|
83
|
+
|
|
84
|
+
@table_schema = table_schema
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def table_schema
|
|
88
|
+
@table_schema
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Represents the concept of response in the case of a DROP query executed on the database of an AS/400 server by a PeaClient object.
|
|
93
|
+
|
|
94
|
+
class PeaDropResponse < PeaResponse
|
|
95
|
+
|
|
96
|
+
##
|
|
97
|
+
# Initialize a new instance of the PeaDropResponse class.
|
|
98
|
+
#
|
|
99
|
+
# Params:
|
|
100
|
+
# +has_succeeded+:: Boolean set to true if the query has correctly been executed. Set to true if the SQL state is 00000.
|
|
101
|
+
# +sql_message+:: SQL message return from the execution of the query.
|
|
102
|
+
# +sql_state+:: SQL state return from the execution of the query.
|
|
103
|
+
|
|
104
|
+
def initialize(has_succeeded, sql_message, sql_state)
|
|
105
|
+
super has_succeeded, sql_message, sql_state
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Represents the concept of response in the case of a SELECT query executed on the database of an AS/400 server by a PeaClient object.
|
|
110
|
+
|
|
111
|
+
class PeaSelectResponse < PeaResponse
|
|
112
|
+
|
|
113
|
+
##
|
|
114
|
+
# Initialize a new instance of the PeaSelectResponse class.
|
|
115
|
+
#
|
|
116
|
+
# Params:
|
|
117
|
+
# +has_succeeded+:: Boolean set to true if the query has correctly been executed. Set to true if the SQL state is 00000.
|
|
118
|
+
# +sql_message+:: SQL message return from the execution of the query.
|
|
119
|
+
# +sql_state+:: SQL state return from the execution of the query.
|
|
120
|
+
# +result+:: Results of the query in the form of an Dictionary where the columns' name are the key and the values are the elements of this column in the SQL table.
|
|
121
|
+
# +row_count+:: Represents the number of rows that have been retreived by the query.
|
|
122
|
+
# +columns_name+:: Array representing the name of the columns in the order of the SELECT query.
|
|
123
|
+
|
|
124
|
+
def initialize(has_succeeded, sql_message, sql_state, result, row_count, columns_name)
|
|
125
|
+
super has_succeeded, sql_message, sql_state
|
|
126
|
+
|
|
127
|
+
@result = result
|
|
128
|
+
@row_count = row_count
|
|
129
|
+
@columns_name = columns_name
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def result
|
|
133
|
+
@result
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def row_count
|
|
137
|
+
@row_count
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def columns_name
|
|
141
|
+
@columns_name
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# Represents the concept of response in the case of an UPDATE query executed on the database of an AS/400 server by a PeaClient object.
|
|
146
|
+
|
|
147
|
+
class PeaUpdateResponse < PeaResponse
|
|
148
|
+
|
|
149
|
+
##
|
|
150
|
+
# Initialize a new instance of the PeaResponse class.
|
|
151
|
+
#
|
|
152
|
+
# Params:
|
|
153
|
+
# +has_succeeded+:: Boolean set to true if the query has correctly been executed. Set to true if the SQL state is 00000.
|
|
154
|
+
# +sql_message+:: SQL message return from the execution of the query.
|
|
155
|
+
# +sql_state+:: SQL state return from the execution of the query.
|
|
156
|
+
# +row_count+:: Represents the number of rows that have been updated by the query.
|
|
157
|
+
|
|
158
|
+
def initialize(has_succeeded, sql_message, sql_state, row_count)
|
|
159
|
+
super has_succeeded, sql_message, sql_state
|
|
160
|
+
|
|
161
|
+
@row_count = row_count
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def row_count
|
|
165
|
+
@row_count
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# Represents the concept of response in the case of a DELETE query executed on the database of an AS/400 server by a PeaClient object.
|
|
170
|
+
|
|
171
|
+
class PeaDeleteResponse < PeaResponse
|
|
172
|
+
|
|
173
|
+
##
|
|
174
|
+
# Initialize a new instance of the PeaResponse class.
|
|
175
|
+
#
|
|
176
|
+
# Params:
|
|
177
|
+
# +has_succeeded+:: Boolean set to true if the query has correctly been executed. Set to true if the SQL state is 00000.
|
|
178
|
+
# +sql_message+:: SQL message return from the execution of the query.
|
|
179
|
+
# +sql_state+:: SQL state return from the execution of the query.
|
|
180
|
+
# +row_count+:: Represents the number of rows that have been updated by the query.
|
|
181
|
+
|
|
182
|
+
def initialize(has_succeeded, sql_message, sql_state, row_count)
|
|
183
|
+
super has_succeeded, sql_message, sql_state
|
|
184
|
+
|
|
185
|
+
@row_count = row_count
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def row_count
|
|
189
|
+
@row_count
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# Represents the concept of response in the case of an INSERT query executed on the database of an AS/400 server by a PeaClient object.
|
|
194
|
+
|
|
195
|
+
class PeaInsertResponse < PeaResponse
|
|
196
|
+
|
|
197
|
+
##
|
|
198
|
+
# Initialize a new instance of the PeaResponse class.
|
|
199
|
+
#
|
|
200
|
+
# Params:
|
|
201
|
+
# +has_succeeded+:: Boolean set to true if the query has correctly been executed. Set to true if the SQL state is 00000.
|
|
202
|
+
# +sql_message+:: SQL message return from the execution of the query.
|
|
203
|
+
# +sql_state+:: SQL state return from the execution of the query.
|
|
204
|
+
# +row_count+:: Represents the number of rows that have been updated by the query.
|
|
205
|
+
|
|
206
|
+
def initialize(has_succeeded, sql_message, sql_state, row_count)
|
|
207
|
+
super has_succeeded, sql_message, sql_state
|
|
208
|
+
|
|
209
|
+
@row_count = row_count
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
def row_count
|
|
213
|
+
@row_count
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
# Represents the concept of response in the case of an OS/400 command executed on the database of an AS/400 server by a PeaClient object.
|
|
218
|
+
|
|
219
|
+
class PeaCommandResponse
|
|
220
|
+
|
|
221
|
+
##
|
|
222
|
+
# Initialize a new instance of the PeaCommandResponse class.
|
|
223
|
+
#
|
|
224
|
+
# Params:
|
|
225
|
+
# +has_succeeded+:: Boolean set to true if the command has correctly been executed meaning that no CPFxxxx was return. Still, description messages can be return along with CP*xxxx.
|
|
226
|
+
# +warnings+:: List of warnings that results form the command execution. Errors are of the form : CP*xxxx Description of the warning.
|
|
227
|
+
|
|
228
|
+
def initialize(warnings)
|
|
229
|
+
@warnings = warnings
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
def warnings
|
|
233
|
+
@warnings
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Represents the concept of metadata for a column of an SQL table on the AS/400 server.
|
|
238
|
+
class ColumnInfo
|
|
239
|
+
|
|
240
|
+
##
|
|
241
|
+
# Initialize a new instance of the ColumnInfo class.
|
|
242
|
+
#
|
|
243
|
+
# Params:
|
|
244
|
+
# +column_name+:: Name of the column.
|
|
245
|
+
# +ordinal_position+:: Ordinal position of the column.
|
|
246
|
+
# +data_type+:: DB2 Type of the data contain in the column.
|
|
247
|
+
# +length+:: Length of the data contain in the column.
|
|
248
|
+
# +numeric_scale+:: Scale of the data contain in the column if numeric type.
|
|
249
|
+
# +is_nullable+:: Y/N depending on the nullability of the field.
|
|
250
|
+
# +is_updatable+:: Y/N depending on the updaptability of the field.
|
|
251
|
+
# +numeric_precision+:: Precision of the data contain in the column if numeric type.
|
|
252
|
+
|
|
253
|
+
def initialize(column_name, ordinal_position, data_type, length, numeric_scale, is_nullable, is_updatable, numeric_precision)
|
|
254
|
+
@column_name = column_name
|
|
255
|
+
@ordinal_position = ordinal_position
|
|
256
|
+
@data_type = data_type
|
|
257
|
+
@length = length
|
|
258
|
+
@numeric_scale = numeric_scale
|
|
259
|
+
@numeric_precision = numeric_precision
|
|
260
|
+
@is_nullable = is_nullable
|
|
261
|
+
@is_updatable = is_updatable
|
|
262
|
+
@numeric_precision = numeric_precision
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
def column_name
|
|
266
|
+
@column_name
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
def ordinal_position
|
|
270
|
+
@ordinal_position
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
def data_type
|
|
274
|
+
@data_type
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
def length
|
|
278
|
+
@length
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
def numeric_scale
|
|
282
|
+
@numeric_scale
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
def numeric_precision
|
|
286
|
+
@numeric_precision
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
def is_nullable
|
|
290
|
+
@is_nullable
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
def is_updatable
|
|
294
|
+
@is_updatable
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
def numeric_precision
|
|
298
|
+
@numeric_precision
|
|
299
|
+
end
|
|
300
300
|
end
|
data/lib/peasys-ruby.rb
ADDED