hanami-model 1.0.0.beta1 → 1.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 396fbb6a95d9e5526ff1e2415246d0bebc3f8413
4
- data.tar.gz: 67a3c00a1e9c29ced838ba349082db34262edd1d
3
+ metadata.gz: 6ef0a3e682c1e1d8b32295f6e14d70ad8a0c9ea7
4
+ data.tar.gz: ce2eccfc1037fa3a89ea65a44e8f4754a10eba5a
5
5
  SHA512:
6
- metadata.gz: b47a74240ea4e92273809b248531ce3d06b301b4e6ab5dc9e588f8bd1297157d368b1ee4725281a401f578db1fbf17a698be2a03844718c8f7c73c594e19288b
7
- data.tar.gz: 9307402f7125c83e3d9e3e1b1365ffb7cdcb661167bc1348969e52d13658edbf0ba28110e4923b1da4a1461554ee308564a9b6853b2240633ffb4c517975677f
6
+ metadata.gz: 461e105d7804802a456d77c3518e78aff4369fa88a68585f46f1ed648c99bf602fa41e3faae4f7b6bc941282ba0ddc48ce93f23d263f34adcf2c185b14ee24fd
7
+ data.tar.gz: e2a85018d9fb67ec84476cb6f69ae1510e3455ef96856a56c69dbdb86c1630d31f077966b70cd487d6e5cabfc9595b2f8ec432d2c6eadcbec4ba4ad82e63de9a
data/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
  # Hanami::Model
2
2
  A persistence layer for Hanami
3
3
 
4
+ ## v1.0.0.beta2 - 2017-03-02
5
+ ### Added
6
+ - [Semyon Pupkov] Allow to define Postgres connection URL as `"postgresql:///mydb?host=localhost&port=6433&user=postgres&password=testpasswd"`
7
+
8
+ ### Fixed
9
+ - [Marcello Rocha] Fixed migrations MySQL detection of username and password
10
+ - [Luca Guidi] Fixed migrations creation/drop of a MySQL database with a dash in the name
11
+ - [Semyon Pupkov] Ensure `db console` to work when Postgres connection URL is defined with `"postgresql://"` scheme
12
+
4
13
  ## v1.0.0.beta1 - 2017-02-14
5
14
  ### Added
6
15
  - [Luca Guidi] Official support for Ruby: MRI 2.4
data/hanami-model.gemspec CHANGED
@@ -20,8 +20,8 @@ Gem::Specification.new do |spec|
20
20
  spec.required_ruby_version = '>= 2.3.0'
21
21
 
22
22
  spec.add_runtime_dependency 'hanami-utils', '~> 1.0.0.beta'
23
- spec.add_runtime_dependency 'rom-sql', '~> 1.0'
24
- spec.add_runtime_dependency 'rom-repository', '~> 1.0'
23
+ spec.add_runtime_dependency 'rom-sql', '~> 1.1'
24
+ spec.add_runtime_dependency 'rom-repository', '~> 1.2'
25
25
  spec.add_runtime_dependency 'dry-types', '~> 0.9'
26
26
  spec.add_runtime_dependency 'concurrent-ruby', '~> 1.0'
27
27
 
@@ -34,7 +34,7 @@ module Hanami
34
34
  # @since 0.5.0
35
35
  # @api private
36
36
  def host
37
- @host ||= parsed_uri.host
37
+ @host ||= parsed_uri.host || parsed_opt('host')
38
38
  end
39
39
 
40
40
  # Returns DB connection port
@@ -44,7 +44,7 @@ module Hanami
44
44
  # @since 0.5.0
45
45
  # @api private
46
46
  def port
47
- @port ||= parsed_uri.port
47
+ @port ||= parsed_uri.port || parsed_opt('port').to_i.nonzero?
48
48
  end
49
49
 
50
50
  # Returns DB name from conenction
@@ -83,7 +83,7 @@ module Hanami
83
83
  # @since 0.5.0
84
84
  # @api private
85
85
  def user
86
- @user ||= parsed_opt('user')
86
+ @user ||= parsed_opt('user') || parsed_uri.user
87
87
  end
88
88
 
89
89
  # Returns user from DB connection
@@ -93,7 +93,7 @@ module Hanami
93
93
  # @since 0.5.0
94
94
  # @api private
95
95
  def password
96
- @password ||= parsed_opt('password')
96
+ @password ||= parsed_opt('password') || parsed_uri.password
97
97
  end
98
98
 
99
99
  # Returns DB connection URI directly from adapter
@@ -19,7 +19,7 @@ module Hanami
19
19
  # @since 0.4.0
20
20
  # @api private
21
21
  def create
22
- new_connection(global: true).run %(CREATE DATABASE #{database};)
22
+ new_connection(global: true).run %(CREATE DATABASE `#{database}`;)
23
23
  rescue Sequel::DatabaseError => e
24
24
  message = if e.message.match(/database exists/) # rubocop:disable Performance/RedundantMatch
25
25
  DB_CREATION_ERROR
@@ -33,7 +33,7 @@ module Hanami
33
33
  # @since 0.4.0
34
34
  # @api private
35
35
  def drop
36
- new_connection(global: true).run %(DROP DATABASE #{database};)
36
+ new_connection(global: true).run %(DROP DATABASE `#{database}`;)
37
37
  rescue Sequel::DatabaseError => e
38
38
  message = if e.message.match(/doesn\'t exist/) # rubocop:disable Performance/RedundantMatch
39
39
  "Cannot find database: #{database}"
@@ -27,7 +27,7 @@ module Hanami
27
27
  when 'sqlite'
28
28
  require 'hanami/model/sql/consoles/sqlite'
29
29
  Sql::Consoles::Sqlite.new(@uri)
30
- when 'postgres'
30
+ when 'postgres', 'postgresql'
31
31
  require 'hanami/model/sql/consoles/postgresql'
32
32
  Sql::Consoles::Postgresql.new(@uri)
33
33
  when 'mysql', 'mysql2'
@@ -3,6 +3,6 @@ module Hanami
3
3
  # Defines the version
4
4
  #
5
5
  # @since 0.1.0
6
- VERSION = '1.0.0.beta1'.freeze
6
+ VERSION = '1.0.0.beta2'.freeze
7
7
  end
8
8
  end
@@ -274,9 +274,13 @@ module Hanami
274
274
 
275
275
  # @since 0.7.0
276
276
  # @api private
277
- def self.inherited(klass) # rubocop:disable Metrics/MethodLength
277
+ #
278
+ # rubocop:disable Metrics/MethodLength
279
+ # rubocop:disable Metrics/AbcSize
280
+ def self.inherited(klass)
278
281
  klass.class_eval do
279
282
  include Utils::ClassAttribute
283
+ auto_struct true
280
284
 
281
285
  class_attribute :entity
282
286
 
@@ -292,6 +296,8 @@ module Hanami
292
296
 
293
297
  Hanami::Model.repositories << klass
294
298
  end
299
+ # rubocop:enable Metrics/AbcSize
300
+ # rubocop:enable Metrics/MethodLength
295
301
 
296
302
  # Extend commands from ROM::Repository with error management
297
303
  #
@@ -419,7 +425,7 @@ module Hanami
419
425
  # @example
420
426
  # UserRepository.new.first
421
427
  def first
422
- root.as(:entity).first
428
+ root.as(:entity).limit(1).one
423
429
  end
424
430
 
425
431
  # Returns the last record for the relation
@@ -431,7 +437,7 @@ module Hanami
431
437
  # @example
432
438
  # UserRepository.new.last
433
439
  def last
434
- root.order(Model::Sql.desc(root.primary_key)).as(:entity).first
440
+ root.as(:entity).limit(1).reverse.one
435
441
  end
436
442
 
437
443
  # Deletes all the records from the relation
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta1
4
+ version: 1.0.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-02-14 00:00:00.000000000 Z
13
+ date: 2017-03-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: hanami-utils
@@ -32,28 +32,28 @@ dependencies:
32
32
  requirements:
33
33
  - - "~>"
34
34
  - !ruby/object:Gem::Version
35
- version: '1.0'
35
+ version: '1.1'
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: '1.0'
42
+ version: '1.1'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: rom-repository
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: '1.0'
49
+ version: '1.2'
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: '1.0'
56
+ version: '1.2'
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: dry-types
59
59
  requirement: !ruby/object:Gem::Requirement