gda 1.1.3 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -15
- data/ext/gda/extconf.rb +12 -8
- data/ext/gda/gda.c +64 -7
- data/ext/gda/gda.h +3 -0
- data/ext/gda/gda_nodes.c +29 -17
- data/ext/gda/gda_nodes.h +1 -1
- data/ext/gda/gda_provider.c +20 -6
- data/ext/gda/gda_provider.h +1 -1
- data/ext/gda/gda_statement.c +31 -14
- data/ext/gda/gda_statement.h +1 -1
- data/lib/gda/version.rb +1 -1
- data/lib/gda/visitors/dot.rb +11 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3d2ee26e57caf91e7aca441c227da8bb08151832e2204657919e9d1b460779f
|
4
|
+
data.tar.gz: e1fa55cfef56159e03af7fe8a98fd6d18471956a3b63e15b1120eb8c816227a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91516f5fee707e47dbc2954cf5a5f26f02069f234449bef6265010f01ecc411d6d2c2ad18c6d1f3e9299ae073899bc8a87a3470163d2060f78568e2285b998ce
|
7
|
+
data.tar.gz: e495e7841c2931c45b825ba5aa11821f68ca843e11f309678c07f23e4591bd0067800f1efdd39606dfd49adcde6b35c5cc27083459b8f2cba78025c82d8098c4
|
data/README.md
CHANGED
@@ -1,40 +1,44 @@
|
|
1
|
-
|
1
|
+
# gda
|
2
2
|
|
3
3
|
* http://github.com/tenderlove/gda
|
4
4
|
|
5
|
-
|
5
|
+
## DESCRIPTION:
|
6
6
|
|
7
7
|
An SQL parser. Wraps libgda in a loving embrace to give you a ruby level SQL
|
8
8
|
parser.
|
9
9
|
|
10
|
-
|
10
|
+
## SYNOPSIS:
|
11
11
|
|
12
|
-
|
12
|
+
```ruby
|
13
|
+
parser = GDA::SQL::Parser.new
|
13
14
|
|
14
|
-
|
15
|
+
stmt = parser.parse 'SELECT * FROM FOO WHERE 1 = 1 GROUP BY omg HAVING omg(id) < 2 ORDER BY foo, bar LIMIT 50 OFFSET 2'
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
stmt.ast.each do |node|
|
18
|
+
p node
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
+
puts stmt.ast.to_dot
|
22
|
+
```
|
21
23
|
|
22
|
-
|
24
|
+
## HACKING
|
23
25
|
|
24
26
|
$ brew install libgda
|
25
27
|
$ gem install hoe rake-compiler
|
26
28
|
$ rake
|
27
29
|
|
28
|
-
== INSTALL:
|
29
30
|
|
30
|
-
|
31
|
-
* gem install gda
|
31
|
+
## INSTALL
|
32
32
|
|
33
|
-
|
33
|
+
|
34
|
+
$ brew install libgda
|
35
|
+
$ gem install gda
|
36
|
+
|
37
|
+
## LICENSE
|
34
38
|
|
35
39
|
(The MIT License)
|
36
40
|
|
37
|
-
Copyright (c) 2012-
|
41
|
+
Copyright (c) 2012-2023 Aaron Patterson
|
38
42
|
|
39
43
|
Permission is hereby granted, free of charge, to any person obtaining
|
40
44
|
a copy of this software and associated documentation files (the
|
data/ext/gda/extconf.rb
CHANGED
@@ -7,17 +7,21 @@ ENV['PKG_CONFIG_PATH'] ||= '/usr/local/lib/pkgconfig'
|
|
7
7
|
dir_config 'libgda'
|
8
8
|
|
9
9
|
def asplode missing
|
10
|
-
abort
|
11
|
-
#{missing} is missing. Try 'brew install libgda' if you are on OSX and have homebrew installed.
|
12
|
-
You can also check https://github.com/GNOME/libgda for more info on how to install
|
13
|
-
the dependency.
|
14
|
-
MSG
|
10
|
+
abort <<~MSG
|
11
|
+
#{missing} is missing. Try 'brew install pkg-config libgda' if you are on OSX and have homebrew installed.
|
12
|
+
You can also check https://github.com/GNOME/libgda for more info on how to install
|
13
|
+
the dependency.
|
14
|
+
MSG
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
available_libgda_pkg_config = nil
|
18
|
+
%w(5.0 6.0).each do |pkg_config_version|
|
19
|
+
pkg_config "libgda-#{pkg_config_version}"
|
20
|
+
available_libgda_pkg_config = find_header('libgda/sql-parser/gda-sql-parser.h')
|
21
|
+
break if available_libgda_pkg_config
|
22
|
+
end
|
19
23
|
|
24
|
+
asplode("libgda") unless available_libgda_pkg_config
|
20
25
|
create_makefile 'gda'
|
21
26
|
|
22
|
-
|
23
27
|
# :startdoc:
|
data/ext/gda/gda.c
CHANGED
@@ -4,12 +4,65 @@ VALUE mGDA;
|
|
4
4
|
VALUE mSQL;
|
5
5
|
VALUE cParser;
|
6
6
|
|
7
|
+
static void parser_free(void *data)
|
8
|
+
{
|
9
|
+
g_object_unref((GdaSqlParser *)data);
|
10
|
+
}
|
11
|
+
|
12
|
+
static size_t parser_memsize(const void *data)
|
13
|
+
{
|
14
|
+
return sizeof(GdaSqlParser);
|
15
|
+
}
|
16
|
+
|
17
|
+
static const rb_data_type_t parser_type = {
|
18
|
+
"GDA::SQL::Parser",
|
19
|
+
{
|
20
|
+
NULL,
|
21
|
+
parser_free,
|
22
|
+
parser_memsize,
|
23
|
+
},
|
24
|
+
0,
|
25
|
+
0,
|
26
|
+
RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
27
|
+
};
|
28
|
+
|
29
|
+
VALUE gda_parser_wrap(VALUE klass, GdaSqlParser * parser)
|
30
|
+
{
|
31
|
+
return TypedData_Wrap_Struct(klass, &parser_type, parser);
|
32
|
+
}
|
33
|
+
|
7
34
|
static VALUE allocate(VALUE klass)
|
8
35
|
{
|
9
|
-
|
36
|
+
return gda_parser_wrap(klass, gda_sql_parser_new());
|
37
|
+
}
|
10
38
|
|
11
|
-
|
12
|
-
|
39
|
+
static void statement_free(void *data)
|
40
|
+
{
|
41
|
+
g_object_unref((GdaStatement *)data);
|
42
|
+
}
|
43
|
+
|
44
|
+
static size_t statement_memsize(const void *data)
|
45
|
+
{
|
46
|
+
return sizeof(GdaStatement);
|
47
|
+
}
|
48
|
+
|
49
|
+
static const rb_data_type_t statement_type = {
|
50
|
+
"GDA::SQL::Statement",
|
51
|
+
{
|
52
|
+
NULL,
|
53
|
+
statement_free,
|
54
|
+
statement_memsize,
|
55
|
+
},
|
56
|
+
0,
|
57
|
+
0,
|
58
|
+
RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
59
|
+
};
|
60
|
+
|
61
|
+
GdaStatement *gda_statement_unwrap(VALUE self)
|
62
|
+
{
|
63
|
+
GdaStatement * stmt;
|
64
|
+
TypedData_Get_Struct(self, GdaStatement, &statement_type, stmt);
|
65
|
+
return stmt;
|
13
66
|
}
|
14
67
|
|
15
68
|
static VALUE parse(VALUE self, VALUE sql)
|
@@ -19,7 +72,7 @@ static VALUE parse(VALUE self, VALUE sql)
|
|
19
72
|
GError * error = NULL;
|
20
73
|
const gchar * rest;
|
21
74
|
|
22
|
-
|
75
|
+
TypedData_Get_Struct(self, GdaSqlParser, &parser_type, parser);
|
23
76
|
|
24
77
|
stmt = gda_sql_parser_parse_string(parser, StringValuePtr(sql), &rest, &error);
|
25
78
|
|
@@ -27,7 +80,7 @@ static VALUE parse(VALUE self, VALUE sql)
|
|
27
80
|
rb_raise(rb_eRuntimeError, "error parsing sql");
|
28
81
|
}
|
29
82
|
|
30
|
-
return
|
83
|
+
return TypedData_Wrap_Struct(cStatement, &statement_type, stmt);
|
31
84
|
}
|
32
85
|
|
33
86
|
static VALUE providers(VALUE klass)
|
@@ -75,15 +128,19 @@ static VALUE sql_identifier_split(VALUE klass, VALUE string)
|
|
75
128
|
return ids;
|
76
129
|
}
|
77
130
|
|
78
|
-
void Init_gda()
|
131
|
+
void Init_gda(void)
|
79
132
|
{
|
80
|
-
|
133
|
+
rb_global_variable(&mGDA);
|
81
134
|
mGDA = rb_define_module("GDA");
|
135
|
+
|
136
|
+
rb_global_variable(&mSQL);
|
82
137
|
mSQL = rb_define_module_under(mGDA, "SQL");
|
83
138
|
|
84
139
|
Init_gda_statement();
|
85
140
|
Init_gda_nodes();
|
86
141
|
Init_gda_provider();
|
142
|
+
|
143
|
+
rb_global_variable(&cParser);
|
87
144
|
cParser = rb_define_class_under(mSQL, "Parser", rb_cObject);
|
88
145
|
|
89
146
|
rb_define_alloc_func(cParser, allocate);
|
data/ext/gda/gda.h
CHANGED
@@ -11,6 +11,9 @@ extern VALUE mSQL;
|
|
11
11
|
extern VALUE cStatement;
|
12
12
|
extern VALUE cParser;
|
13
13
|
|
14
|
+
GdaStatement *gda_statement_unwrap(VALUE stmt);
|
15
|
+
VALUE gda_parser_wrap(VALUE klass, GdaSqlParser * parser);
|
16
|
+
|
14
17
|
#include <gda_statement.h>
|
15
18
|
#include <gda_nodes.h>
|
16
19
|
#include <gda_provider.h>
|
data/ext/gda/gda_nodes.c
CHANGED
@@ -25,11 +25,23 @@ VALUE cRollback;
|
|
25
25
|
VALUE cCommit;
|
26
26
|
VALUE cCompound;
|
27
27
|
|
28
|
+
static const rb_data_type_t any_part_type = {
|
29
|
+
"GDA::SQL::AnyPart",
|
30
|
+
{
|
31
|
+
NULL,
|
32
|
+
NULL,
|
33
|
+
NULL,
|
34
|
+
},
|
35
|
+
0,
|
36
|
+
0,
|
37
|
+
RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
38
|
+
};
|
39
|
+
|
28
40
|
#define WrapInteger(klass, type, lname) \
|
29
41
|
static VALUE rb_##klass##_##lname(VALUE self) \
|
30
42
|
{ \
|
31
43
|
type *st;\
|
32
|
-
|
44
|
+
TypedData_Get_Struct(self, type, &any_part_type, st); \
|
33
45
|
return INT2NUM(st->lname); \
|
34
46
|
}
|
35
47
|
|
@@ -37,7 +49,7 @@ VALUE cCompound;
|
|
37
49
|
static VALUE rb_##klass##_##lname(VALUE self) \
|
38
50
|
{ \
|
39
51
|
type *st;\
|
40
|
-
|
52
|
+
TypedData_Get_Struct(self, type, &any_part_type, st); \
|
41
53
|
if (st->lname) \
|
42
54
|
return Qtrue; \
|
43
55
|
else \
|
@@ -48,7 +60,7 @@ VALUE cCompound;
|
|
48
60
|
static VALUE rb_##klass##_##lname(VALUE self) \
|
49
61
|
{ \
|
50
62
|
type *st;\
|
51
|
-
|
63
|
+
TypedData_Get_Struct(self, type, &any_part_type, st); \
|
52
64
|
if (st->lname) \
|
53
65
|
return rb_str_new2(st->lname); \
|
54
66
|
else \
|
@@ -60,7 +72,7 @@ VALUE cCompound;
|
|
60
72
|
{ \
|
61
73
|
type *st;\
|
62
74
|
VALUE stmt;\
|
63
|
-
|
75
|
+
TypedData_Get_Struct(self, type, &any_part_type, st); \
|
64
76
|
stmt = rb_iv_get(self, "stmt"); \
|
65
77
|
return WrapAnyPart(stmt, (GdaSqlAnyPart *)st->lname); \
|
66
78
|
}
|
@@ -72,7 +84,7 @@ VALUE cCompound;
|
|
72
84
|
GSList *list; \
|
73
85
|
VALUE rb_list; \
|
74
86
|
VALUE stmt; \
|
75
|
-
|
87
|
+
TypedData_Get_Struct(self, type, &any_part_type, ptr);\
|
76
88
|
stmt = rb_iv_get(self, "stmt"); \
|
77
89
|
rb_list = rb_ary_new(); \
|
78
90
|
list = ptr->lname; \
|
@@ -155,7 +167,7 @@ static VALUE distinct_p(VALUE self)
|
|
155
167
|
{
|
156
168
|
GdaSqlStatementSelect * st;
|
157
169
|
|
158
|
-
|
170
|
+
TypedData_Get_Struct(self, GdaSqlStatementSelect, &any_part_type, st);
|
159
171
|
|
160
172
|
if (st->distinct)
|
161
173
|
return Qtrue;
|
@@ -165,7 +177,7 @@ static VALUE distinct_p(VALUE self)
|
|
165
177
|
|
166
178
|
static VALUE Wrap(VALUE stmt, VALUE klass, GdaSqlAnyPart *part)
|
167
179
|
{
|
168
|
-
VALUE obj =
|
180
|
+
VALUE obj = TypedData_Wrap_Struct(klass, &any_part_type, part);
|
169
181
|
rb_iv_set(obj, "stmt", stmt);
|
170
182
|
return obj;
|
171
183
|
}
|
@@ -256,7 +268,7 @@ static VALUE rb_cCompound_stmt_list(VALUE self)
|
|
256
268
|
VALUE array;
|
257
269
|
VALUE stmt;
|
258
270
|
|
259
|
-
|
271
|
+
TypedData_Get_Struct(self, GdaSqlStatementCompound, &any_part_type, st);
|
260
272
|
stmt = rb_iv_get(self, "stmt");
|
261
273
|
array = rb_ary_new();
|
262
274
|
|
@@ -276,7 +288,7 @@ static VALUE rb_cInsert_values_list(VALUE self)
|
|
276
288
|
VALUE array;
|
277
289
|
VALUE stmt;
|
278
290
|
|
279
|
-
|
291
|
+
TypedData_Get_Struct(self, GdaSqlStatementInsert, &any_part_type, st);
|
280
292
|
|
281
293
|
stmt = rb_iv_get(self, "stmt");
|
282
294
|
|
@@ -302,7 +314,7 @@ static VALUE rb_cOperation_operator(VALUE self)
|
|
302
314
|
{
|
303
315
|
GdaSqlOperation * st;
|
304
316
|
|
305
|
-
|
317
|
+
TypedData_Get_Struct(self, GdaSqlOperation, &any_part_type, st);
|
306
318
|
|
307
319
|
if (st->operator_type)
|
308
320
|
return rb_str_new2(gda_sql_operation_operator_to_string(st->operator_type));
|
@@ -314,7 +326,7 @@ static VALUE rb_cJoin_join_type(VALUE self)
|
|
314
326
|
{
|
315
327
|
GdaSqlSelectJoin * st;
|
316
328
|
|
317
|
-
|
329
|
+
TypedData_Get_Struct(self, GdaSqlSelectJoin, &any_part_type, st);
|
318
330
|
|
319
331
|
if (st->type)
|
320
332
|
return rb_str_new2(gda_sql_select_join_type_to_string(st->type));
|
@@ -326,7 +338,7 @@ static VALUE rb_st_type(VALUE self)
|
|
326
338
|
{
|
327
339
|
GdaSqlAnyPart * st;
|
328
340
|
|
329
|
-
|
341
|
+
TypedData_Get_Struct(self, GdaSqlAnyPart, &any_part_type, st);
|
330
342
|
|
331
343
|
switch(st->type) {
|
332
344
|
case GDA_SQL_ANY_STMT_BEGIN:
|
@@ -356,7 +368,7 @@ static VALUE rb_st_isolation_level(VALUE self)
|
|
356
368
|
{
|
357
369
|
GdaSqlStatementTransaction * st;
|
358
370
|
|
359
|
-
|
371
|
+
TypedData_Get_Struct(self, GdaSqlStatementTransaction, &any_part_type, st);
|
360
372
|
|
361
373
|
switch(st->isolation_level) {
|
362
374
|
default:
|
@@ -382,7 +394,7 @@ static VALUE rb_st_trans_mode(VALUE self)
|
|
382
394
|
{
|
383
395
|
GdaSqlStatementTransaction * st;
|
384
396
|
|
385
|
-
|
397
|
+
TypedData_Get_Struct(self, GdaSqlStatementTransaction, &any_part_type, st);
|
386
398
|
|
387
399
|
if (st->trans_mode)
|
388
400
|
return rb_str_new2(st->trans_mode);
|
@@ -394,7 +406,7 @@ static VALUE rb_st_trans_name(VALUE self)
|
|
394
406
|
{
|
395
407
|
GdaSqlStatementTransaction * st;
|
396
408
|
|
397
|
-
|
409
|
+
TypedData_Get_Struct(self, GdaSqlStatementTransaction, &any_part_type, st);
|
398
410
|
|
399
411
|
if (st->trans_name)
|
400
412
|
return rb_str_new2(st->trans_name);
|
@@ -407,14 +419,14 @@ static VALUE rb_cExpr_value(VALUE self)
|
|
407
419
|
GdaSqlExpr * st;
|
408
420
|
GValue * val;
|
409
421
|
|
410
|
-
|
422
|
+
TypedData_Get_Struct(self, GdaSqlExpr, &any_part_type, st);
|
411
423
|
|
412
424
|
val = st->value;
|
413
425
|
|
414
426
|
return rb_str_new2(gda_value_stringify(val));
|
415
427
|
}
|
416
428
|
|
417
|
-
void Init_gda_nodes()
|
429
|
+
void Init_gda_nodes(void)
|
418
430
|
{
|
419
431
|
mNodes = rb_define_module_under(mGDA, "Nodes");
|
420
432
|
|
data/ext/gda/gda_nodes.h
CHANGED
data/ext/gda/gda_provider.c
CHANGED
@@ -2,10 +2,22 @@
|
|
2
2
|
|
3
3
|
VALUE cProvider;
|
4
4
|
|
5
|
+
static const rb_data_type_t provider_type = {
|
6
|
+
"GDA::SQL::Provider",
|
7
|
+
{
|
8
|
+
NULL,
|
9
|
+
NULL,
|
10
|
+
NULL,
|
11
|
+
},
|
12
|
+
0,
|
13
|
+
0,
|
14
|
+
RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
15
|
+
};
|
16
|
+
|
5
17
|
static VALUE name(VALUE self)
|
6
18
|
{
|
7
19
|
GdaServerProvider * pr;
|
8
|
-
|
20
|
+
TypedData_Get_Struct(self, GdaServerProvider, &provider_type, pr);
|
9
21
|
|
10
22
|
return rb_str_new2(gda_server_provider_get_name(pr));
|
11
23
|
}
|
@@ -18,7 +30,7 @@ static VALUE find(VALUE klass, VALUE string)
|
|
18
30
|
pr = gda_config_get_provider(StringValuePtr(string), &error);
|
19
31
|
|
20
32
|
if (pr)
|
21
|
-
return
|
33
|
+
return TypedData_Wrap_Struct(klass, &provider_type, pr);
|
22
34
|
else {
|
23
35
|
/* FIXME: should actually raise an error here. */
|
24
36
|
g_error_free(error);
|
@@ -31,27 +43,29 @@ static VALUE parser(VALUE self)
|
|
31
43
|
GdaSqlParser * parser;
|
32
44
|
GdaServerProvider * pr;
|
33
45
|
|
34
|
-
|
46
|
+
TypedData_Get_Struct(self, GdaServerProvider, &provider_type, pr);
|
35
47
|
|
36
48
|
parser = gda_server_provider_create_parser(pr, NULL);
|
37
49
|
|
38
50
|
if (!parser)
|
39
51
|
rb_raise(rb_eRuntimeError, "zomglol");
|
40
52
|
|
41
|
-
return
|
53
|
+
return gda_parser_wrap(cParser, parser);
|
42
54
|
}
|
43
55
|
|
44
56
|
static VALUE quote_str(VALUE self, VALUE str)
|
45
57
|
{
|
46
58
|
GdaServerProvider * pr;
|
47
59
|
|
48
|
-
|
60
|
+
TypedData_Get_Struct(self, GdaServerProvider, &provider_type, pr);
|
49
61
|
return rb_str_new2(gda_sql_identifier_quote(StringValuePtr(str), NULL, pr, TRUE, TRUE));
|
50
62
|
}
|
51
63
|
|
52
|
-
void Init_gda_provider()
|
64
|
+
void Init_gda_provider(void)
|
53
65
|
{
|
66
|
+
rb_global_variable(&cProvider);
|
54
67
|
cProvider = rb_define_class_under(mSQL, "Provider", rb_cObject);
|
68
|
+
|
55
69
|
rb_undef_alloc_func(cProvider);
|
56
70
|
rb_define_singleton_method(cProvider, "find", find, 1);
|
57
71
|
rb_define_method(cProvider, "name", name, 0);
|
data/ext/gda/gda_provider.h
CHANGED
data/ext/gda/gda_statement.c
CHANGED
@@ -3,13 +3,33 @@
|
|
3
3
|
VALUE cStatement;
|
4
4
|
VALUE cStructure;
|
5
5
|
|
6
|
+
static void structure_free(void *data)
|
7
|
+
{
|
8
|
+
gda_sql_statement_free((GdaSqlStatement *)data);
|
9
|
+
}
|
10
|
+
|
11
|
+
static size_t structure_memsize(const void *data)
|
12
|
+
{
|
13
|
+
return sizeof(GdaSqlStatement);
|
14
|
+
}
|
15
|
+
|
16
|
+
static const rb_data_type_t structure_type = {
|
17
|
+
"GDA::SQL::Structure",
|
18
|
+
{
|
19
|
+
NULL,
|
20
|
+
structure_free,
|
21
|
+
structure_memsize,
|
22
|
+
},
|
23
|
+
0,
|
24
|
+
0,
|
25
|
+
RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
26
|
+
};
|
27
|
+
|
6
28
|
static VALUE serialize(VALUE self)
|
7
29
|
{
|
8
|
-
GdaStatement * stmt;
|
30
|
+
GdaStatement * stmt = gda_statement_unwrap(self);
|
9
31
|
gchar * string;
|
10
32
|
|
11
|
-
Data_Get_Struct(self, GdaStatement, stmt);
|
12
|
-
|
13
33
|
string = gda_statement_serialize(stmt);
|
14
34
|
return rb_str_new2(string);
|
15
35
|
}
|
@@ -17,36 +37,33 @@ static VALUE serialize(VALUE self)
|
|
17
37
|
static VALUE ast(VALUE self)
|
18
38
|
{
|
19
39
|
GdaSqlStatement * sqlst;
|
20
|
-
|
21
|
-
Data_Get_Struct(self, GdaSqlStatement, sqlst);
|
22
|
-
|
40
|
+
TypedData_Get_Struct(self, GdaSqlStatement, &structure_type, sqlst);
|
23
41
|
return WrapAnyPart(self, GDA_SQL_ANY_PART(sqlst->contents));
|
24
42
|
}
|
25
43
|
|
26
44
|
static VALUE sql(VALUE self)
|
27
45
|
{
|
28
46
|
GdaSqlStatement * sqlst;
|
29
|
-
|
30
|
-
Data_Get_Struct(self, GdaSqlStatement, sqlst);
|
31
|
-
|
47
|
+
TypedData_Get_Struct(self, GdaSqlStatement, &structure_type, sqlst);
|
32
48
|
return rb_str_new2(sqlst->sql);
|
33
49
|
}
|
34
50
|
|
35
51
|
static VALUE structure(VALUE self)
|
36
52
|
{
|
37
|
-
GdaStatement * stmt;
|
53
|
+
GdaStatement * stmt = gda_statement_unwrap(self);
|
38
54
|
GdaSqlStatement * sqlst;
|
39
55
|
|
40
|
-
Data_Get_Struct(self, GdaStatement, stmt);
|
41
|
-
|
42
56
|
g_object_get(G_OBJECT(stmt), "structure", &sqlst, NULL);
|
43
57
|
|
44
|
-
return
|
58
|
+
return TypedData_Wrap_Struct(cStructure, &structure_type, sqlst);
|
45
59
|
}
|
46
60
|
|
47
|
-
void Init_gda_statement()
|
61
|
+
void Init_gda_statement(void)
|
48
62
|
{
|
63
|
+
rb_global_variable(&cStatement);
|
49
64
|
cStatement = rb_define_class_under(mSQL, "Statement", rb_cObject);
|
65
|
+
|
66
|
+
rb_global_variable(&cStructure);
|
50
67
|
cStructure = rb_define_class_under(mSQL, "Structure", rb_cObject);
|
51
68
|
|
52
69
|
rb_undef_alloc_func(cStatement);
|
data/ext/gda/gda_statement.h
CHANGED
data/lib/gda/version.rb
CHANGED
data/lib/gda/visitors/dot.rb
CHANGED
@@ -32,19 +32,19 @@ module GDA
|
|
32
32
|
@buffer.printf(*args)
|
33
33
|
end
|
34
34
|
|
35
|
-
NODE = ERB.new
|
36
|
-
node<%= node.object_id %> [shape="plaintext" label=<
|
37
|
-
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
|
38
|
-
<TR><TD COLSPAN="2"><%= node.class %></TD></TR>
|
39
|
-
<% attrs.each do |attr| %>
|
40
|
-
|
41
|
-
|
42
|
-
<% end %>
|
43
|
-
</TABLE>>];
|
35
|
+
NODE = ERB.new <<~eoerb
|
36
|
+
node<%= node.object_id %> [shape="plaintext" label=<
|
37
|
+
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
|
38
|
+
<TR><TD COLSPAN="2"><%= node.class %></TD></TR>
|
39
|
+
<% attrs.each do |attr| %>
|
40
|
+
<% next if node.send(attr).nil? %>
|
41
|
+
<TR><TD><%= ERB::Util.h attr %></TD><TD><%= ERB::Util.h node.send(attr) %></TD></TR>
|
42
|
+
<% end %>
|
43
|
+
</TABLE>>];
|
44
44
|
eoerb
|
45
45
|
|
46
|
-
LIST = ERB.new
|
47
|
-
node<%= node.object_id %> [shape="invhouse", color=gray, fontcolor=gray, label=list];
|
46
|
+
LIST = ERB.new <<~eoerb
|
47
|
+
node<%= node.object_id %> [shape="invhouse", color=gray, fontcolor=gray, label=list];
|
48
48
|
eoerb
|
49
49
|
|
50
50
|
def add_node node, attrs = []
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Patterson
|
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: 2.5.0
|
63
63
|
requirements: []
|
64
|
-
rubygems_version: 3.
|
64
|
+
rubygems_version: 3.5.0.dev
|
65
65
|
signing_key:
|
66
66
|
specification_version: 4
|
67
67
|
summary: An SQL parser
|