Comments (18)
Yep, are u using it with padrino?
The query problem is due to a reloading issue.
I've also have a problem with the connection not closed, but also doesn't depend from MiniRecord but from an api change https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb#L418
I think (but I need to check) this will occurs only with some webservers like thin or so.
from mini_record.
Yes, I'm using padrino.... It does it in Webrick, thin and apache + passenger. Is there anyway to fix the issue(s)? They seem like pretty big ones......
from mini_record.
Always running query should solved with a stop/restart of the webserver or touch tmp/restart.txt
under passenger.
The connection problem Im unable to reproduce it this because sometimes happens others not.
You have an idea how to reproduce it?
from mini_record.
Always running query should solved with a stop/restart
how do you mean? I've started and stopped the server a bunch of times and it still runs those queries every time.
The connection problem Im unable to reproduce it this because sometimes happens others not.
It happens on every 6 th page load/db connection, so my guess it's to do with :pool => 5,
in the ActiveRecord::Base.configurations
10:55 ~/Dropbox/sd/acd/receptionist (master *3)$ padrino start
DEPRECATION WARNING: Yajl's JSON gem compatibility API is going to be removed in 2.0
INFO - Running any db changes.
DEBUG - (46.5ms) ALTER TABLE `calls` CHANGE `direction` `direction` ENUM('inbound', 'outbound') DEFAULT NULL
DEBUG - (22.3ms) ALTER TABLE `calls` CHANGE `receptionist_id` `receptionist_id` int(11) DEFAULT NULL
DEBUG - (15.6ms) ALTER TABLE `calls` CHANGE `closed` `closed` tinyint(1) DEFAULT 0
DEBUG - (33.3ms) ALTER TABLE `calls` CHANGE `holiday` `holiday` tinyint(1) DEFAULT 0
=> Padrino/0.10.6.c has taken the stage development at http://0.0.0.0:3000
[2012-02-03 10:55:46] INFO WEBrick 1.3.1
[2012-02-03 10:55:46] INFO ruby 1.9.3 (2011-10-30) [x86_64-darwin11.2.0]
[2012-02-03 10:55:46] INFO WEBrick::HTTPServer#start: pid=60370 port=3000
INFO - Running any db changes.
DEBUG - (13.7ms) ALTER TABLE `calls` CHANGE `direction` `direction` ENUM('inbound', 'outbound') DEFAULT NULL
DEBUG - (10.2ms) ALTER TABLE `calls` CHANGE `receptionist_id` `receptionist_id` int(11) DEFAULT NULL
DEBUG - (8.0ms) ALTER TABLE `calls` CHANGE `closed` `closed` tinyint(1) DEFAULT 0
DEBUG - (11.8ms) ALTER TABLE `calls` CHANGE `holiday` `holiday` tinyint(1) DEFAULT 0
DEBUG - User Load (3.4ms) SELECT `users`.* FROM `users` WHERE `users`.`acd_api_uid` = 8345 LIMIT 1
DEBUG - TEMPLATE (0.0003ms) /dashboard.html
DEBUG - TEMPLATE (0.0001ms) /layouts/application.html
DEBUG - GET (0.2109ms) / - 200 OK
DEBUG - GET (0.2897ms) /css/bootstrap/bootstrap.621727.css - 200 OK
INFO - Running any db changes.
DEBUG - (26.1ms) ALTER TABLE `calls` CHANGE `direction` `direction` ENUM('inbound', 'outbound') DEFAULT NULL
DEBUG - (10.9ms) ALTER TABLE `calls` CHANGE `receptionist_id` `receptionist_id` int(11) DEFAULT NULL
DEBUG - (8.9ms) ALTER TABLE `calls` CHANGE `closed` `closed` tinyint(1) DEFAULT 0
DEBUG - (14.7ms) ALTER TABLE `calls` CHANGE `holiday` `holiday` tinyint(1) DEFAULT 0
DEBUG - User Load (0.9ms) SELECT `users`.* FROM `users` WHERE `users`.`acd_api_uid` = 8345 LIMIT 1
DEBUG - TEMPLATE (0.0003ms) /dashboard.html
DEBUG - TEMPLATE (0.0001ms) /layouts/application.html
DEBUG - GET (0.1360ms) / - 200 OK
DEBUG - GET (0.3349ms) /css/bootstrap/bootstrap.621727.css - 200 OK
INFO - Running any db changes.
DEBUG - (21.7ms) ALTER TABLE `calls` CHANGE `direction` `direction` ENUM('inbound', 'outbound') DEFAULT NULL
DEBUG - (11.5ms) ALTER TABLE `calls` CHANGE `receptionist_id` `receptionist_id` int(11) DEFAULT NULL
DEBUG - (9.0ms) ALTER TABLE `calls` CHANGE `closed` `closed` tinyint(1) DEFAULT 0
DEBUG - (13.9ms) ALTER TABLE `calls` CHANGE `holiday` `holiday` tinyint(1) DEFAULT 0
DEBUG - User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`acd_api_uid` = 8345 LIMIT 1
DEBUG - TEMPLATE (0.0003ms) /dashboard.html
DEBUG - TEMPLATE (0.0001ms) /layouts/application.html
DEBUG - GET (0.1245ms) / - 200 OK
INFO - Running any db changes.
DEBUG - (14.1ms) ALTER TABLE `calls` CHANGE `direction` `direction` ENUM('inbound', 'outbound') DEFAULT NULL
DEBUG - (9.6ms) ALTER TABLE `calls` CHANGE `receptionist_id` `receptionist_id` int(11) DEFAULT NULL
DEBUG - (13.7ms) ALTER TABLE `calls` CHANGE `closed` `closed` tinyint(1) DEFAULT 0
DEBUG - (17.2ms) ALTER TABLE `calls` CHANGE `holiday` `holiday` tinyint(1) DEFAULT 0
DEBUG - GET (0.4412ms) /css/bootstrap/bootstrap.621727.css - 200 OK
INFO - Running any db changes.
DEPRECATION WARNING: Database connections will not be closed automatically, please close your
database connection at the end of the thread by calling `close` on your
connection. For example: ActiveRecord::Base.connection.close
. (called from mon_synchronize at /Users/cj/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/monitor.rb:211)
DEPRECATION WARNING: Database connections will not be closed automatically, please close your
database connection at the end of the thread by calling `close` on your
connection. For example: ActiveRecord::Base.connection.close
. (called from mon_synchronize at /Users/cj/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/monitor.rb:211)
DEPRECATION WARNING: Database connections will not be closed automatically, please close your
database connection at the end of the thread by calling `close` on your
connection. For example: ActiveRecord::Base.connection.close
. (called from mon_synchronize at /Users/cj/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/monitor.rb:211)
DEPRECATION WARNING: Database connections will not be closed automatically, please close your
database connection at the end of the thread by calling `close` on your
connection. For example: ActiveRecord::Base.connection.close
. (called from mon_synchronize at /Users/cj/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/monitor.rb:211)
DEBUG - (19.1ms) ALTER TABLE `calls` CHANGE `direction` `direction` ENUM('inbound', 'outbound') DEFAULT NULL
DEBUG - (19.2ms) ALTER TABLE `calls` CHANGE `receptionist_id` `receptionist_id` int(11) DEFAULT NULL
DEBUG - (19.2ms) ALTER TABLE `calls` CHANGE `closed` `closed` tinyint(1) DEFAULT 0
DEBUG - (11.4ms) ALTER TABLE `calls` CHANGE `holiday` `holiday` tinyint(1) DEFAULT 0
DEBUG - User Load (0.5ms) SELECT `users`.* FROM `users` WHERE `users`.`acd_api_uid` = 8345 LIMIT 1
DEBUG - TEMPLATE (0.0003ms) /dashboard.html
DEBUG - TEMPLATE (0.0001ms) /layouts/application.html
DEBUG - GET (5.3785ms) / - 200 OK
DEBUG - GET (0.3383ms) /css/bootstrap/bootstrap.621727.css - 200 OK
from mini_record.
Problem one should be solved replacing this:
col :closed, :holiday, as: :boolean, default: 0
into:
col :closed, :holiday, as: :boolean, default: false
from mini_record.
So I think once query problem will be solved also connection closed will be.
from mini_record.
Looks like you just need to add ActiveRecord::Base.connection.close
to the end of auto_upgrade!
from mini_record.
@cj mmm can be, but be sure to use true or false
when the col is :boolean
the migration will fail so for that reason will be performed every time.
from mini_record.
Problem one should be solved replacing this:
col :closed, :holiday, as: :boolean, default: 0
into:
col :closed, :holiday, as: :boolean, default: false
Now I'm just left with:
DEBUG - (40.4ms) ALTER TABLE `calls` CHANGE `direction` `direction` ENUM('inbound', 'outbound') DEFAULT NULL
DEBUG - (14.9ms) ALTER TABLE `calls` CHANGE `receptionist_id` `receptionist_id` int(11) DEFAULT NULL
With this schema:
schema { |t| t.column :direction, "ENUM('inbound', 'outbound')" }
add_index :direction
col :receptionist_id, as: :integer, limit: 11, index: true
col :closed, :holiday, as: :boolean, default: false
col :to, :from, :sid, :api_version, :status, index: true
col :start, :end, as: :datetime
col :duration, as: :integer
timestamps
from mini_record.
This col :receptionist_id, as: :integer, limit: 11, index: true
should be solved removing the limit
col :receptionist_id, as: :integer, index: true
from mini_record.
I need the limit (at the db level) though :)
from mini_record.
If Im not wrong AR add it for you, so is not necessary.
from mini_record.
Surely that is a bug though because if I want to limit a string size or limit an integer to 5 it's still going to happen.... same when using schema
from mini_record.
Perfect! I will add some specs and solve the issue!
from mini_record.
Thank you :)
from mini_record.
After digging a bit into this issue, there is no way to solve it.
When you use :limit => 11
mysql adapter convert it to :limit => 4
class Task < ActiveRecord::Base
key :priority, :limit => 11
end
# ALTER TABLE `tasks` CHANGE `priority` `priority` int(11)
Task.auto_upgrade!
Now checking:
cols = ActiveRecord::Base.connection.columns('tasks').inject({}) { |hash, col| hash[col.name] = col; hash }
So now if we check the db limit:
cols['priority'].limit
It returns: 4
.
This because in MySql Adapter of ActiveRecord we have this:
case limit
when 1; 'tinyint'
when 2; 'smallint'
when 3; 'mediumint'
when nil, 4, 11; 'int(11)' # compatibility with MySQL default
when 5..8; 'bigint'
else raise(ActiveRecordError, "No integer type has byte size #{limit}")
end
Here another problem, I cant remap
those values back because are specific for MySql
, nor Sqlite
or Postgres
have this kind of mapping.
So the problem I think is quite small, this happens only when you use integer limit
, so If you are using i.e. limit: 11
it's better to translate it directly to limit: 4
since it creates limit: 11
.
Thoughts ?
from mini_record.
Is there no way to add some logic to ignore limit 11? Just so that if someone does enter it at least the query won't run every time. Also what about the big issue of schema { |t| t.column :direction, "ENUM('inbound', 'outbound')" }
running every page request?
from mini_record.
You haven't any kind of problems if you use any values different than 4
or 11
since both are stored as default.
Check updated test for more info.
This happens only with integers none occurs with string or other types.
For the second problem, make me a pull request (if you have time) with only a failing test
.
Thank you man!
from mini_record.
Related Issues (20)
- Issue about primary keys HOT 2
- ActiveRecord - Abstract class bug. HOT 1
- mini_record incompatible with Rails 4.0 HOT 4
- Idea for handling changing column names HOT 6
- macro facility - useful/interesting? HOT 3
- sqlite3 rewrites the table on every auto_upgrade HOT 2
- Problems with SQLite HOT 2
- MiniRecord don't work without logger HOT 4
- has_and_belongs_to_many join table name issues HOT 1
- wrong table name. bug introduced in my last PR HOT 1
- auto_upgrade! fails because of attempting to add duplicate indexes
- Auto changing column type don't work on PostgreSQL HOT 5
- auto_upgrade! sometimes breaks has_and_belongs_to_many associations
- Partial indexes for PostgreSQL?
- PostgreSQL limitless columns? HOT 3
- how to use mini_record in sinatra?
- "Unsupported number of args for ActiveRecord::ConnectionAdapters::TableDefinition.new() (ArgumentError)" HOT 2
- PostgreSQL booleans not supported HOT 1
- Not related: GoTasks for Mac
- auto_upgrade! NameError: no member 'limit' in struct HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mini_record.