extralite 3.0.0 → 3.0.1
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/CHANGELOG.md +5 -0
- data/TODO.md +54 -2
- data/ext/extralite/database.c +1 -1
- data/lib/extralite/version.rb +1 -1
- data/test/test_transform.rb +15 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 22e7b14b0233f008d2b7e0c252d14eee96c736f028266eac5be6193356ce9969
|
|
4
|
+
data.tar.gz: a2e4b6c13ecb6bf1c660b621c3da919ff9ab9d460cefe6bf1d4a2dc06e16b285
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 79b7e334dc09a45c6819027e8d6ee3a2e2e16faa82f4811989562caba93a688a629c78d9c3a53564d89a47ca9aa7ee9f2447663761d8931dd0cf2c4d69a8ed15
|
|
7
|
+
data.tar.gz: 9312ce8e55e1bfb121f36c93820b701217fc5abb90b5d3c2995a871c0ced0f876d9abd26b6a60cdcc57bb920a982eeb3ce572dd1f6c674a56f8227abde7fd19a
|
data/CHANGELOG.md
CHANGED
data/TODO.md
CHANGED
|
@@ -1,2 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
## Transforms
|
|
2
|
+
|
|
3
|
+
- Add ability to exclude a column:
|
|
4
|
+
|
|
5
|
+
```ruby
|
|
6
|
+
Extralite::Transform.new do
|
|
7
|
+
{
|
|
8
|
+
id: integer.identity,
|
|
9
|
+
title: text,
|
|
10
|
+
content: text,
|
|
11
|
+
tags: [{
|
|
12
|
+
id: integer.identity.skip,
|
|
13
|
+
name: text
|
|
14
|
+
}]
|
|
15
|
+
}
|
|
16
|
+
end
|
|
17
|
+
#=>
|
|
18
|
+
[
|
|
19
|
+
{
|
|
20
|
+
id: 1,
|
|
21
|
+
title: 'foo',
|
|
22
|
+
content: 'bar',
|
|
23
|
+
tags: [
|
|
24
|
+
{ name: 'baz' },
|
|
25
|
+
{ name: 'bug' }
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- Can we get rid of the hash container?
|
|
32
|
+
|
|
33
|
+
```ruby
|
|
34
|
+
Extralite::Transform.new do
|
|
35
|
+
{
|
|
36
|
+
id: integer.identity,
|
|
37
|
+
title: text,
|
|
38
|
+
content: text,
|
|
39
|
+
_tag_id: skip,
|
|
40
|
+
tags: [
|
|
41
|
+
name: text
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
end
|
|
45
|
+
#=>
|
|
46
|
+
[
|
|
47
|
+
{
|
|
48
|
+
id: 1,
|
|
49
|
+
title: 'foo',
|
|
50
|
+
content: 'bar',
|
|
51
|
+
tags: [ 'baz', 'bug' ]
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
```
|
data/ext/extralite/database.c
CHANGED
|
@@ -742,7 +742,7 @@ static inline VALUE Database_prepare(int argc, VALUE *argv, VALUE self, VALUE mo
|
|
|
742
742
|
rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
|
|
743
743
|
|
|
744
744
|
VALUE transform = Qnil;
|
|
745
|
-
if (argc > 1 && rb_obj_is_instance_of(argv[0], cTransform)) {
|
|
745
|
+
if (argc > 1 && (NIL_P(argv[0]) || rb_obj_is_instance_of(argv[0], cTransform))) {
|
|
746
746
|
transform = argv[0];
|
|
747
747
|
argv++;
|
|
748
748
|
argc--;
|
data/lib/extralite/version.rb
CHANGED
data/test/test_transform.rb
CHANGED
|
@@ -669,6 +669,21 @@ class TransformPreparedQueryTest < Minitest::Test
|
|
|
669
669
|
assert_equal result[0][:tags][1].object_id, result[1][:tags][0].object_id
|
|
670
670
|
end
|
|
671
671
|
|
|
672
|
+
def test_transform_prepared_query_nil_transform
|
|
673
|
+
q = @db.prepare(nil, @sql)
|
|
674
|
+
|
|
675
|
+
result = q.to_a
|
|
676
|
+
assert_kind_of Array, result
|
|
677
|
+
assert_equal 4, result.size
|
|
678
|
+
|
|
679
|
+
assert_equal [
|
|
680
|
+
{id: 1, title: "T1", content: "C1", name: "tag1"},
|
|
681
|
+
{id: 2, title: "T1", content: "C1", name: "tag2"},
|
|
682
|
+
{id: 2, title: "T2", content: "C2", name: "tag2"},
|
|
683
|
+
{id: 3, title: "T2", content: "C2", name: "tag3"}
|
|
684
|
+
], result
|
|
685
|
+
end
|
|
686
|
+
|
|
672
687
|
def test_transform_prepared_query_each
|
|
673
688
|
t = Extralite::Transform.new(@spec)
|
|
674
689
|
q = @db.prepare(t, @sql)
|