New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uuid doent not generate a timestamp when the object its cached #19039
Comments
Hi @msroot I couldn't reproduce this issue. I attempted the following step.
class PostgresqlUUIDTestCacheKey < ActiveRecord::TestCase
include PostgresqlUUIDHelper
class UuidCacheKeyPost < ActiveRecord::Base
self.table_name = 'pg_uuid_cache_key_posts'
end
setup do
enable_extension!('uuid-ossp', connection)
connection.transaction do
connection.create_table('pg_uuid_cache_key_posts', id: :uuid) do |t|
t.timestamps null: false
end
end
end
teardown do
drop_table "pg_uuid_cache_key_posts"
disable_extension!('uuid-ossp', connection)
end
if ActiveRecord::Base.connection.supports_extensions?
def test_cache_key
post = UuidCacheKeyPost.create!
assert post.cache_key =~ /\h+-\h+-\h+-\h+-\h+-\d+/
puts post.cache_key
end
end
end
But test_cache_key was passed. and I saw a proper cache key string (ex. postgresql_uuid_test_cache_key/uuid_cache_key_posts/46b5a9ae-0799-4e45-a508-250a139ecb09-20150223170642661034881). Could you create an reproduction script with this template https://github.com/rails/rails/blob/master/guides/bug_report_templates/active_record_master.rb? |
# Activate the gem you are reporting the issue against.
gem 'activerecord', '4.1.6'
require 'active_record'
require 'minitest/autorun'
require 'logger'
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'postgresql', database: 'test_uuid')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table "posts", id: :uuid, default: "uuid_generate_v4()", force: true do |t|
enable_extension 'uuid-ossp'
t.timestamps
end
end
class Post < ActiveRecord::Base
end
class BugTest < Minitest::Test
def test_uuid
post = Post.create!
puts post.cache_key
assert post.cache_key =~ /\h+-\h+-\h+-\h+-\h+-\d+/
end
end I run this and it pass! I got This is my Schema: create_table "languages", id: :uuid, default: "uuid_generate_v4()", force: true do |t|
t.string "name"
t.string "yahoo"
t.string "lang"
t.string "code"
t.string "flag"
end Here is my Gemfile GEM
remote: https://rubygems.org/
specs:
abstract_type (0.0.7)
actionmailer (4.1.6)
actionpack (= 4.1.6)
actionview (= 4.1.6)
mail (~> 2.5, >= 2.5.4)
actionpack (4.1.6)
actionview (= 4.1.6)
activesupport (= 4.1.6)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
actionview (4.1.6)
activesupport (= 4.1.6)
builder (~> 3.1)
erubis (~> 2.7.0)
active_median (0.1.2)
activerecord
activemodel (4.1.6)
activesupport (= 4.1.6)
builder (~> 3.1)
activerecord (4.1.6)
activemodel (= 4.1.6)
activesupport (= 4.1.6)
arel (~> 5.0.0)
activesupport (4.1.6)
i18n (~> 0.6, >= 0.6.9)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
adamantium (0.2.0)
ice_nine (~> 0.11.0)
memoizable (~> 0.4.0)
addressable (2.3.7)
annotate (2.6.5)
activerecord (>= 2.3.0)
rake (>= 0.8.7)
arel (5.0.1.20140414130214)
arrayfields (4.9.2)
ast (2.0.0)
aws_cf_signer (0.1.3)
bcrypt (3.1.10)
better_errors (2.1.1)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
rack (>= 0.9.0)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
bootstrap-generators (3.0.2.2)
railties (>= 3.1)
builder (3.2.2)
byebug (3.5.1)
columnize (~> 0.8)
debugger-linecache (~> 1.2)
slop (~> 3.6)
cane (2.6.2)
parallel
carrierwave (0.10.0)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
json (>= 1.7)
mime-types (>= 1.16)
chartkick (1.3.2)
choice (0.1.7)
chronic (0.10.2)
churn (0.0.35)
chronic (>= 0.2.3)
hirb
json_pure
main
rest-client (>= 1.6.0)
ruby_parser (~> 3.0)
sexp_processor (~> 4.1)
cloudinary (1.0.82)
aws_cf_signer
rest-client
cocoon (1.2.6)
code_analyzer (0.4.5)
sexp_processor
code_metrics (0.1.3)
coderay (1.1.0)
colored (1.2)
columnize (0.9.0)
concord (0.1.5)
adamantium (~> 0.2.0)
equalizer (~> 0.0.9)
dalli (2.7.2)
debug_inspector (0.0.2)
debugger-linecache (1.2.0)
devise (3.4.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
responders
thread_safe (~> 0.1)
warden (~> 1.2.3)
diff-lcs (1.2.5)
easy_translate (0.5.0)
json
thread
thread_safe
email_validator (1.5.0)
activemodel
equalizer (0.0.9)
erubis (2.7.0)
excon (0.44.2)
execjs (2.3.0)
faker (1.4.3)
i18n (~> 0.5)
faraday (0.9.1)
multipart-post (>= 1.2, < 3)
fattr (2.2.2)
flay (2.6.1)
ruby_parser (~> 3.0)
sexp_processor (~> 4.0)
flog (4.3.2)
ruby_parser (~> 3.1, > 3.1.0)
sexp_processor (~> 4.4)
groupdate (2.4.0)
activesupport (>= 3)
high_voltage (2.2.1)
highline (1.7.0)
hike (1.2.3)
hirb (0.7.3)
http_accept_language (2.0.5)
i18n (0.7.0)
i18n-tasks (0.7.12)
activesupport
easy_translate (>= 0.5.0)
erubis
highline
i18n
slop (~> 3.5)
term-ansicolor
terminal-table
ice_nine (0.11.1)
jquery-rails (3.1.2)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.2)
json_pure (1.8.2)
jwt (1.2.1)
kgio (2.9.3)
launchy (2.4.3)
addressable (~> 2.3)
lol_dba (1.6.4)
actionpack (>= 3.0)
activerecord (>= 3.0)
railties (>= 3.0)
mail (2.6.3)
mime-types (>= 1.16, < 3)
mail_form (1.5.0)
actionmailer (>= 3.2, < 5)
activemodel (>= 3.2, < 5)
main (6.1.0)
arrayfields (>= 4.7.4)
chronic (>= 0.6.2)
fattr (>= 2.2.0)
map (>= 5.1.0)
map (6.5.5)
memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1)
metric_fu (4.11.3)
cane (~> 2.5, >= 2.5.2)
churn (~> 0.0.35)
code_metrics (~> 0.1)
coderay
flay (~> 2.1, >= 2.0.1)
flog (~> 4.1, >= 4.1.1)
launchy (~> 2.0)
metric_fu-Saikuro (~> 1.1, >= 1.1.3)
multi_json
rails_best_practices (~> 1.14, >= 1.14.3)
redcard
reek (~> 1.3, >= 1.3.4)
roodi (~> 3.1)
metric_fu-Saikuro (1.1.3)
mime-types (2.4.3)
mini_portile (0.6.2)
minitest (5.5.1)
multi_json (1.10.1)
multi_xml (0.5.5)
multipart-post (2.0.0)
netrc (0.10.2)
newrelic_rpm (3.10.0.279)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
oauth (0.4.7)
oauth2 (1.0.0)
faraday (>= 0.8, < 0.10)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (~> 1.2)
orm_adapter (0.5.0)
parallel (1.4.0)
parser (2.2.0.3)
ast (>= 1.1, < 3.0)
pg (0.18.1)
procto (0.0.2)
quiet_assets (1.1.0)
railties (>= 3.1, < 5.0)
rack (1.5.2)
rack-mini-profiler (0.9.2)
rack (>= 1.1.3)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.1.6)
actionmailer (= 4.1.6)
actionpack (= 4.1.6)
actionview (= 4.1.6)
activemodel (= 4.1.6)
activerecord (= 4.1.6)
activesupport (= 4.1.6)
bundler (>= 1.3.0, < 2.0)
railties (= 4.1.6)
sprockets-rails (~> 2.0)
rails-erd (1.3.0)
activerecord (>= 3.2)
activesupport (>= 3.2)
choice (~> 0.1.6)
ruby-graphviz (~> 1.0.4)
rails-footnotes (4.1.5)
rails (>= 3.2)
rails-i18n (4.0.3)
i18n (~> 0.6)
railties (~> 4.0)
rails_12factor (0.0.3)
rails_serve_static_assets
rails_stdout_logging
rails_best_practices (1.15.6)
activesupport
code_analyzer (>= 0.4.3)
colored
erubis
i18n
json
require_all
ruby-progressbar
rails_serve_static_assets (0.0.4)
rails_stdout_logging (0.0.3)
railties (4.1.6)
actionpack (= 4.1.6)
activesupport (= 4.1.6)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.0.0)
raindrops (0.13.0)
rake (10.4.2)
redcard (1.1.0)
reek (1.6.6)
parser (~> 2.2.0.pre.7)
rainbow (>= 1.99, < 3.0)
unparser (~> 0.2.2)
require_all (1.3.2)
responders (1.1.2)
railties (>= 3.2, < 4.2)
rest-client (1.7.3)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
roodi (3.3.1)
ruby_parser (~> 3.2, >= 3.2.2)
ruby-graphviz (1.0.9)
ruby-progressbar (1.7.1)
ruby_parser (3.6.4)
sexp_processor (~> 4.1)
sexp_processor (4.4.5)
simple_form (3.1.0)
actionpack (~> 4.0)
activemodel (~> 4.0)
simple_oauth (0.3.1)
slop (3.6.0)
spring (1.3.2)
sprockets (2.12.3)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.2.4)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
term-ansicolor (1.3.0)
tins (~> 1.0)
terminal-table (1.4.5)
thor (0.19.1)
thread (0.1.5)
thread_safe (0.3.4)
tilt (1.4.1)
tins (1.3.4)
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (2.7.0)
execjs (>= 0.3.0)
json (>= 1.8.0)
unicorn (4.8.3)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
unparser (0.2.2)
abstract_type (~> 0.0.7)
adamantium (~> 0.2.0)
concord (~> 0.1.5)
diff-lcs (~> 1.2.5)
equalizer (~> 0.0.9)
parser (~> 2.2.0.2)
procto (~> 0.0.2)
validate_url (1.0.0)
activemodel (>= 3.0.0)
addressable
warden (1.2.3)
rack (>= 1.0)
will_paginate (3.0.7)
will_paginate-bootstrap (1.0.1)
will_paginate (>= 3.0.3)
youtube_it (2.4.2)
builder
excon
faraday (>= 0.8, < 0.10)
json (~> 1.8)
nokogiri (~> 1.6.0)
oauth (~> 0.4.4)
oauth2 (~> 1.0.0)
simple_oauth (>= 0.1.5)
PLATFORMS
ruby
DEPENDENCIES
active_median
annotate
better_errors
binding_of_caller
bootstrap-generators (~> 3.0.2)
byebug
carrierwave
chartkick
cloudinary
cocoon
dalli
devise
email_validator
faker
groupdate
high_voltage
http_accept_language
i18n-tasks
jquery-rails
lol_dba
mail_form
metric_fu
newrelic_rpm
pg
quiet_assets
rack-mini-profiler
rails (= 4.1.6)
rails-erd
rails-footnotes (>= 4.0.0, < 5)
rails-i18n (~> 4.0.0)
rails_12factor
simple_form
spring
uglifier (>= 1.3.0)
unicorn
validate_url
will_paginate (~> 3.0)
will_paginate-bootstrap
youtube_it |
I just create a new rails application without any plugin and it seems like its works fine 2.1.3 :001 > p = Post.create
(0.1ms) BEGIN
SQL (1.8ms) INSERT INTO "posts" ("created_at", "updated_at") VALUES ($1, $2) RETURNING "id" [["created_at", "2015-02-24 08:57:55.801574"], ["updated_at", "2015-02-24 08:57:55.801574"]]
(0.4ms) COMMIT
=> #<Post id: "f3aa57b7-a76e-490c-b9bf-0d57d90582a4", created_at: "2015-02-24 08:57:55", updated_at: "2015-02-24 08:57:55">
2.1.3 :002 > p.cache_key
=> "posts/f3aa57b7-a76e-490c-b9bf-0d57d90582a4-20150224085755801574000"
2.1.3 :003 > So the problem generated from a Gem's bug |
does
|
@kennyj my bad man! I am sorry 2.1.3 :004 > Language.first.cache_key
Language Load (1.0ms) SELECT "languages".* FROM "languages" ORDER BY name LIMIT 1
=> "languages/fdc43b52-1917-43ff-9602-03e2d7796daa-20150225052746876584000"
2.1.3 :005 > |
When i am using a uuid in my model and i am cache it its doent not generate the last updated attribute
How can can i cache models with uuid?
http://guides.rubyonrails.org/caching_with_rails.html
At rubyonrails.org:
Notice that in this example we used cache_key method, so the resulting cache-key will be something like products/233-20140225082222765838000/competing_price. cache_key generates a string based on the model’s id and updated_at attributes. This is a common convention and has the benefit of invalidating the cache whenever the product is updated. In general, when you use low-level caching for instance level information, you need to generate a cache key.
The text was updated successfully, but these errors were encountered: