autoforme 1.12.0 → 1.13.0

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
  SHA256:
3
- metadata.gz: '08b9c95c4e096845f520e6543543f644d9fc7f558ae6c8674ac508a5a392e18a'
4
- data.tar.gz: 51b362ce883daf920aaa4035d1f5cd2073b96c78f54aad0c1411308d08b794d7
3
+ metadata.gz: 2bff68076c7cdf213c0142df9ab3809d33ede301c99f12e5cfbe7d1e111df30d
4
+ data.tar.gz: d2446bc814e6a19ebb70dfd46717ac596bb0aa4915abf02dd83aded973ba8d65
5
5
  SHA512:
6
- metadata.gz: b9ed3dece202d2d48cc6b65746ba979acc57d3b1f67843b4d123d531313162bbf5806c1200ce9bce932eef9dd3aefd7ba1ff6582083b99dc171c8fb90e725c16
7
- data.tar.gz: 7ad255b23d6ebbf43b6ff5caf43c7772b40386451aed7cfe456a09707b05b849e41bb763fe58f7df91940987602cf11972f41e9237b7d49c2ca554d55621769d
6
+ metadata.gz: '048c064a080ae50bd872be8e17a96f06e6f9eece5fb095c31121810edbe2f03d1f5db7a6562fb0d33c7229b1e1a49641246186f6567435664be646da836ce251'
7
+ data.tar.gz: 596b1caa6bfc6a91cf8745019df9c299e9315ace558388c9c5ba4fb44b7df18fdfd0aff0c9e5a7213c71e26ffb3fa12d3afed34e91c962e1ae258254413cded4
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ === 1.13.0 (2024-07-10)
2
+
3
+ * Typecast primary key values before using them for lookup (jeremyevans)
4
+
5
+ * Support colon for model names to allow easier use of namespaced models (adam12) (#46)
6
+
1
7
  === 1.12.0 (2022-06-29)
2
8
 
3
9
  * Handle autocomplete queries with an empty query by returning empty string (jeremyevans)
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013-2021 Jeremy Evans
1
+ Copyright (c) 2013-2024 Jeremy Evans
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to
@@ -23,7 +23,7 @@ module AutoForme
23
23
  # :nocov:
24
24
  end
25
25
 
26
- path_id = $1 if remaining_path =~ %r{\A\/([\w-]+)\z}
26
+ path_id = $1 if remaining_path =~ %r{\A\/([:\w-]+)\z}
27
27
  set_id(path_id)
28
28
  end
29
29
 
@@ -69,7 +69,7 @@ module AutoForme
69
69
  suffix = "\\z"
70
70
  end
71
71
  # :nocov:
72
- regexp = %r{#{prefix}/([\w:]+)/(\w+)(?:/([\w-]+))?#{suffix}}
72
+ regexp = %r{#{prefix}/([\w:]+)/(\w+)(?:/([:\w-]+))?#{suffix}}
73
73
  @controller.get regexp, &block
74
74
  @controller.post regexp, &block
75
75
  end
@@ -133,6 +133,12 @@ module AutoForme
133
133
 
134
134
  # Retrieve underlying model instance with matching primary key
135
135
  def with_pk(type, request, pk)
136
+ begin
137
+ pk = typecast_value(model.primary_key, pk)
138
+ rescue S::InvalidValue
139
+ raise S::NoMatchingRow
140
+ end
141
+
136
142
  dataset_for(type, request).with_pk!(pk)
137
143
  end
138
144
 
@@ -183,7 +189,7 @@ module AutoForme
183
189
  ds = ds.where(S.ilike(S.qualify(model.table_name, c), "%#{ds.escape_like(v)}%"))
184
190
  else
185
191
  begin
186
- typecasted_value = model.db.typecast_value(column_type(c), v)
192
+ typecasted_value = typecast_value(c, v)
187
193
  rescue S::InvalidValue
188
194
  ds = ds.where(false)
189
195
  break
@@ -355,6 +361,10 @@ module AutoForme
355
361
 
356
362
  private
357
363
 
364
+ def typecast_value(column, value)
365
+ model.db.typecast_value(column_type(column), value)
366
+ end
367
+
358
368
  def dataset_for(type, request)
359
369
  ds = model.dataset
360
370
  if filter = filter_for
@@ -6,7 +6,7 @@ module AutoForme
6
6
  MAJOR = 1
7
7
 
8
8
  # The minor version of AutoForme, updated for new feature releases of AutoForme.
9
- MINOR = 12
9
+ MINOR = 13
10
10
 
11
11
  # The patch version of AutoForme, updated only for bug fixes from the last
12
12
  # feature release.
@@ -6,7 +6,7 @@ class Roda
6
6
  module RodaPlugins
7
7
  module AutoForme
8
8
  # Require the render plugin, since it is required.
9
- def self.load_dependencies(app, opts={})
9
+ def self.load_dependencies(app, opts={}, &_)
10
10
  app.plugin :render
11
11
  end
12
12
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoforme
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.0
4
+ version: 1.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-29 00:00:00.000000000 Z
11
+ date: 2024-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: forme
@@ -251,7 +251,7 @@ metadata:
251
251
  documentation_uri: http://autoforme.jeremyevans.net
252
252
  mailing_list_uri: https://github.com/jeremyevans/autoforme/discussions
253
253
  source_code_uri: https://github.com/jeremyevans/autoforme
254
- post_install_message:
254
+ post_install_message:
255
255
  rdoc_options:
256
256
  - "--quiet"
257
257
  - "--line-numbers"
@@ -273,8 +273,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
273
273
  - !ruby/object:Gem::Version
274
274
  version: '0'
275
275
  requirements: []
276
- rubygems_version: 3.3.7
277
- signing_key:
276
+ rubygems_version: 3.5.11
277
+ signing_key:
278
278
  specification_version: 4
279
279
  summary: Web Administrative Console for Roda/Sinatra/Rails and Sequel::Model
280
280
  test_files: []