kansas 0.9.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 +7 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +97 -0
- data/Rakefile +11 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/kansas.gemspec +35 -0
- data/lib/kansas.rb +42 -0
- data/lib/kansas/BelongsTo.rb +23 -0
- data/lib/kansas/Database.rb +659 -0
- data/lib/kansas/Expression.rb +361 -0
- data/lib/kansas/Table.rb +102 -0
- data/lib/kansas/TableClass.rb +179 -0
- data/lib/kansas/ToMany.rb +13 -0
- data/lib/kansas/ToOne.rb +29 -0
- data/lib/kansas/adaptors/AdaptorRule.rb +17 -0
- data/lib/kansas/adaptors/Adaptors.rb +24 -0
- data/lib/kansas/adaptors/StandardSQLMixin.rb +106 -0
- data/lib/kansas/adaptors/dbi_rule.rb +8 -0
- data/lib/kansas/patch_dbi.rb +54 -0
- data/lib/kansas/version.rb +3 -0
- data/notes +85 -0
- metadata +138 -0
data/notes
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
I want Kansas to be able to run using DBI, or using a native driver via
|
2
|
+
an adaptor, or even via dbi, but with an adaptor to facilitate special things
|
3
|
+
such as using hinting with Oracle.
|
4
|
+
|
5
|
+
And I want it to remain backwards compatible so that a:
|
6
|
+
|
7
|
+
KSDatabase.new('dbi:Mysql:foo','bar','bif')
|
8
|
+
|
9
|
+
still works.
|
10
|
+
|
11
|
+
So, there needs to be a set of rules to use when evaluating the connection
|
12
|
+
args.
|
13
|
+
|
14
|
+
Kansas should load a default set of rules, but should let them be manipulated.
|
15
|
+
|
16
|
+
Each "rule" is simple. It contains a block that accepts the args passed to new(), and the file to require should that block match.
|
17
|
+
|
18
|
+
Rules are inserted into an array, and select() called on that array, evaluating each of the blocks in turn.
|
19
|
+
If more than one rule matches, they are tried in order. Exceptions are trapped, and the first to succede is the one that will be used.
|
20
|
+
|
21
|
+
Multiple databases should be mappable in Kansas at the same time, and each should live in its own unique namespace, somehow.
|
22
|
+
|
23
|
+
Use database name as part of the classname? So a db foo with a table bar would have its real name as:
|
24
|
+
|
25
|
+
KSDatabse::Foo::Bar
|
26
|
+
|
27
|
+
But could be referred to via the shorthand of KSDatabase::Bar on a first come, first served basis?
|
28
|
+
i.e. if two different databases, each containing a table 'bar', are mapped, only the first table is accessible as KSDatabse::Bar.
|
29
|
+
|
30
|
+
For simple queries, would be nice to do this:
|
31
|
+
|
32
|
+
KSDatabase::Chemicals[173] # find record where primary key matches 173
|
33
|
+
KSDatabase::Chemicals.with_key(:chemical_name)['sodium hydroxide']
|
34
|
+
KSDatabase::Chemicals.with_key(:chemical_name).like '%hydroxide%'
|
35
|
+
KSDatabase::Chemicals.with_key(:manufacturer).with_key(:name)['Wyreth'] # chaining works when following relationships.
|
36
|
+
KSDatabase::Chemicals.select {chemical_name == 'sodium hydroxide'}
|
37
|
+
KSDatabase::Chemicals.select {manufacturer.name == 'Wyreth'}
|
38
|
+
|
39
|
+
-----
|
40
|
+
|
41
|
+
Adaptor code will be responsible for providing the services that Kansas requires. The adaptor may provide those services through DBI or though other mechanisms.
|
42
|
+
|
43
|
+
The adaptor should implement some sort of delegation to the methods that implement it's interface to the datastore, allowing, at a minimum, direct submission of queries to the lower level database interface (whether this is DBI or a direct driver of some sort).
|
44
|
+
|
45
|
+
Connection Management
|
46
|
+
connected? Is the adaptor connected to the db?
|
47
|
+
ping Check that the connection is live
|
48
|
+
disconnect Disconnect DB connection
|
49
|
+
connect Open connection
|
50
|
+
reconnect Disconnection, if necessary, then connect to the db again
|
51
|
+
uptime
|
52
|
+
vendor
|
53
|
+
username
|
54
|
+
password
|
55
|
+
hostname
|
56
|
+
dbname
|
57
|
+
port
|
58
|
+
driver
|
59
|
+
|
60
|
+
DBI emulation; intended to support legacy apps; deprecated
|
61
|
+
do submit SQL for execution; no query data returned
|
62
|
+
prepare prepare a SQL statement for execution
|
63
|
+
execute execute a SQL statement
|
64
|
+
select_one submit and execute a SQL statement, returning a single row
|
65
|
+
select_all submit and execute a SQL statement, returning one or more rows in an array
|
66
|
+
|
67
|
+
Query; query interface
|
68
|
+
select Accepts a Kansas query specification, makes it into something useable for the db, and submits to db, returning selection result
|
69
|
+
count
|
70
|
+
delete
|
71
|
+
insert
|
72
|
+
update
|
73
|
+
escape Takes a query and escapes dangerous characters in it, returning safe query
|
74
|
+
query Passthrough literal query to db; results returned in array
|
75
|
+
|
76
|
+
Metadata
|
77
|
+
tables Returns list of tables in the database
|
78
|
+
columns Returns list of columns in a table
|
79
|
+
indexes Returns a list of indexes on a table
|
80
|
+
|
81
|
+
Kansas should provide a library of standard functions usable by the adaptors for creating SQL.
|
82
|
+
|
83
|
+
The default adaptor list should be autogenerated. That is, it should list only those adaptors that are installed, and if a new one is installed, it should be autopopulated into the list.
|
84
|
+
|
85
|
+
The tricky thing here is positioning. A driver consists of two parts. The driver itself, and the rule. The rule is a simple file that inserts an instance of KSAdaptorRule into a hash.
|
metadata
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kansas
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kirk Haines
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: dbi
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: dbd-mysql
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Object/Relational mapper with a Ruby based query syntax
|
84
|
+
email:
|
85
|
+
- wyhaines@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- CODE_OF_CONDUCT.md
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- bin/console
|
96
|
+
- bin/setup
|
97
|
+
- kansas.gemspec
|
98
|
+
- lib/kansas.rb
|
99
|
+
- lib/kansas/BelongsTo.rb
|
100
|
+
- lib/kansas/Database.rb
|
101
|
+
- lib/kansas/Expression.rb
|
102
|
+
- lib/kansas/Table.rb
|
103
|
+
- lib/kansas/TableClass.rb
|
104
|
+
- lib/kansas/ToMany.rb
|
105
|
+
- lib/kansas/ToOne.rb
|
106
|
+
- lib/kansas/adaptors/AdaptorRule.rb
|
107
|
+
- lib/kansas/adaptors/Adaptors.rb
|
108
|
+
- lib/kansas/adaptors/StandardSQLMixin.rb
|
109
|
+
- lib/kansas/adaptors/dbi_rule.rb
|
110
|
+
- lib/kansas/patch_dbi.rb
|
111
|
+
- lib/kansas/version.rb
|
112
|
+
- notes
|
113
|
+
homepage: https://github.com/wyhaines/kansas
|
114
|
+
licenses:
|
115
|
+
- MIT
|
116
|
+
metadata:
|
117
|
+
allowed_push_host: https://rubygems.org
|
118
|
+
post_install_message:
|
119
|
+
rdoc_options: []
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
requirements: []
|
133
|
+
rubyforge_project:
|
134
|
+
rubygems_version: 2.4.8
|
135
|
+
signing_key:
|
136
|
+
specification_version: 4
|
137
|
+
summary: Object/Relational mapper with a Ruby based query syntax
|
138
|
+
test_files: []
|