The rake specs fail with both MySQL and PostgreSQL

7 views
Skip to first unread message

Kless

unread,
May 20, 2008, 12:40:00 PM5/20/08
to Insoshi
I've checked Insoshi whith both MySQL, PostgreSQL, and SQLite, and the
rake specs only works with SQLite.

Here, you have a config/database.yml example file for PSQL and MySQL:
-------------------------------------------
# PostgreSQL. Versions 7.4 and 8.x are supported.
#
# Install the ruby-postgres driver:
# gem install ruby-postgres
# On Mac OS X:
# gem install ruby-postgres -- --include=/usr/local/pgsql
# On Windows:
# gem install ruby-postgres
# Choose the win32 build.
# Install PostgreSQL and put its /bin directory on your path.
development:
adapter: postgresql
encoding: unicode
database: insoshi
username: Rails
password: rails

# Connect on a TCP socket. Omitted by default since the client uses
a
# domain socket that doesn't need configuration. Windows does not
have
# domain sockets, so uncomment these lines.
#host: localhost
#port: 5432

# Schema search path. The server defaults to $user,public
#schema_search_path: myapp,sharedapp,public

# Minimum log levels, in increasing order:
# debug5, debug4, debug3, debug2, debug1,
# log, notice, warning, error, fatal, and panic
# The server defaults to notice.
#min_messages: warning

# Warning: The database defined as 'test' will be erased and
# re-generated from your development database when you run 'rake'.
# Do not set this db to the same as development or production.
test:
adapter: postgresql
encoding: unicode
database: insoshi_test
username: Rails
password: rails

production:
adapter: postgresql
encoding: unicode
database: insoshi_production
username: Rails
password: rails
-------------------------------------------

-------------------------------------------
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql
# On Mac OS X:
# sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
# On Mac OS X Leopard:
# sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-
config=/usr/local/mysql/bin/mysql_config
# This sets the ARCHFLAGS environment variable to your native
architecture
# On Windows:
# gem install mysql
# Choose the win32 build.
# Install MySQL and put its /bin directory on your path.
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql
encoding: utf8
database: insoshi
username: Rails
password: rails
socket: /var/run/mysqld/mysqld.sock

# Warning: The database defined as 'test' will be erased and
# re-generated from your development database when you run 'rake'.
# Do not set this db to the same as development or production.
test:
adapter: mysql
encoding: utf8
database: insoshi_test
username: Rails
password: rails
socket: /var/run/mysqld/mysqld.sock

production:
adapter: mysql
encoding: utf8
database: insoshi_production
username: Rails
password: rails
socket: /var/run/mysqld/mysqld.sock
-------------------------------------------

And to create the data base:
-------------
$ mysql -u root -p
> create database insoshi; create database insoshi_test; create
database insoshi_production;

> GRANT ALL PRIVILEGES ON insoshi.* to 'Rails'@'localhost'
IDENTIFIED BY 'rails';
> GRANT ALL PRIVILEGES ON insoshi_test.* to 'Rails'@'localhost'
IDENTIFIED BY 'rails';
> GRANT ALL PRIVILEGES ON insoshi_production.* to
'Rails'@'localhost' IDENTIFIED BY 'rails';

> \q
-------------

-------------
# sudo -u postgres createuser Rails --pwprompt --encrypted \
--superuser --no-createrole --no-createdb
# sudo -u postgres createdb insoshi --owner Rails
# sudo -u postgres createdb insoshi_test --owner Rails
# sudo -u postgres createdb insoshi_production --owner Rails
-------------

Michael Hartl

unread,
May 20, 2008, 1:27:15 PM5/20/08
to ins...@googlegroups.com
We're on it. Thanks for letting us know.

Michael

Michael Hartl

unread,
May 20, 2008, 1:30:06 PM5/20/08
to ins...@googlegroups.com
The specs pass for me with MySQL. There is a ticket at Lighthouse
regarding PostgreSQL
(http://insoshi.lighthouseapp.com/projects/9331/tickets/75-postgresql-database-issue#ticket-75-3).

Michael

Kless

unread,
May 20, 2008, 3:04:00 PM5/20/08
to Insoshi
I got *94 failures* with MySQL v5.0.51 on Ubuntu Hardy, x86_64

Michael Hartl

unread,
May 20, 2008, 3:52:06 PM5/20/08
to ins...@googlegroups.com
Strange. Is anyone else having this problem? Let us know if you find
a solution.

Michael

Kless

unread,
May 20, 2008, 3:53:25 PM5/20/08
to Insoshi
Using PostgreSQL 8.3.1 I get 7 failures:

1)
ActiveRecord::StatementInvalid in 'Person associations common contacts
should exclude deactivated people from common contacts'
PGError: ERROR: syntax error at or near «`»
LINE 1: SELECT connections.*, COUNT(contact_id) FROM `connections`
^
: SELECT connections.*, COUNT(contact_id) FROM `connections`
INNER JOIN people contact ON connections.contact_id =
contact.id
WHERE ((person_id = 1402298589 OR person_id = 197432336)
AND status = 0 AND contact.deactivated = 'f')
GROUP BY contact_id
HAVING count(contact_id) = 2 LIMIT 12 OFFSET 0

2)
ActiveRecord::StatementInvalid in 'Person associations common contacts
should have common contacts with someone'
PGError: ERROR: syntax error at or near «`»
LINE 1: SELECT connections.*, COUNT(contact_id) FROM `connections`
^
: SELECT connections.*, COUNT(contact_id) FROM `connections`
INNER JOIN people contact ON connections.contact_id =
contact.id
WHERE ((person_id = 1402298589 OR person_id = 197432336)
AND status = 0 AND contact.deactivated = 'f')
GROUP BY contact_id
HAVING count(contact_id) = 2 LIMIT 12 OFFSET 0

3)
ActiveRecord::StatementInvalid in 'PeopleController show should not
display break up link if not connected'
PGError: ERROR: syntax error at or near «`»
LINE 1: SELECT connections.*, COUNT(contact_id) FROM `connections`
^
: SELECT connections.*, COUNT(contact_id) FROM `connections`
INNER JOIN people contact ON connections.contact_id =
contact.id
WHERE ((person_id = 1402298589 OR person_id = 1830235192)
AND status = 0 AND contact.deactivated = 'f')
GROUP BY contact_id
HAVING count(contact_id) = 2 LIMIT 12 OFFSET 0

4)
ActiveRecord::StatementInvalid in 'PeopleController show should
display break up link if connected'
PGError: ERROR: syntax error at or near «`»
LINE 1: SELECT connections.*, COUNT(contact_id) FROM `connections`
^
: SELECT connections.*, COUNT(contact_id) FROM `connections`
INNER JOIN people contact ON connections.contact_id =
contact.id
WHERE ((person_id = 1402298589 OR person_id = 1830235192)
AND status = 0 AND contact.deactivated = 'f')
GROUP BY contact_id
HAVING count(contact_id) = 2 LIMIT 12 OFFSET 0

5)
ActiveRecord::StatementInvalid in 'PeopleController show should not
display the edit link for other viewers'
PGError: ERROR: syntax error at or near «`»
LINE 1: SELECT connections.*, COUNT(contact_id) FROM `connections`
^
: SELECT connections.*, COUNT(contact_id) FROM `connections`
INNER JOIN people contact ON connections.contact_id =
contact.id
WHERE ((person_id = 1830235192 OR person_id = 1402298589)
AND status = 0 AND contact.deactivated = 'f')
GROUP BY contact_id
HAVING count(contact_id) = 2 LIMIT 12 OFFSET 0

6)
ActiveRecord::StatementInvalid in 'PeopleController show should
display the edit link for current user'
PGError: ERROR: syntax error at or near «`»
LINE 1: SELECT connections.*, COUNT(contact_id) FROM `connections`
^
: SELECT connections.*, COUNT(contact_id) FROM `connections`
INNER JOIN people contact ON connections.contact_id =
contact.id
WHERE ((person_id = 1402298589 OR person_id = 1402298589)
AND status = 0 AND contact.deactivated = 'f')
GROUP BY contact_id
HAVING count(contact_id) = 2 LIMIT 12 OFFSET 0

7)
ActiveRecord::StatementInvalid in 'PeopleController people pages
should have a working show page'
PGError: ERROR: syntax error at or near «`»
LINE 1: SELECT connections.*, COUNT(contact_id) FROM `connections`
^
: SELECT connections.*, COUNT(contact_id) FROM `connections`
INNER JOIN people contact ON connections.contact_id =
contact.id
WHERE ((person_id = 1830235192 OR person_id = 1402298589)
AND status = 0 AND contact.deactivated = 'f')
GROUP BY contact_id
HAVING count(contact_id) = 2 LIMIT 12 OFFSET 0

Finished in 11.859471 seconds

324 examples, 7 failures

Kless

unread,
May 20, 2008, 6:03:06 PM5/20/08
to Insoshi
The bug of PostgreSQL is on *app/models/person.rb*, on the
*common_connections_with* function.

I'm supposed that the bug is on the next SQL sentence

--------------
sql = %(SELECT connections.*, COUNT(contact_id) FROM `connections`
INNER JOIN people contact ON connections.contact_id =
contact.id
WHERE ((person_id = ? OR person_id = ?)
AND status = ? AND contact.deactivated = ?)
GROUP BY contact_id
HAVING count(contact_id) = 2)
--------------

From #postgresql , said me that: "you don't want any quotes at all in
this case."

So, deleting the back quotes(`) from connections solve this issue, but
it shows now another issues...

megatoast

unread,
Jun 3, 2008, 10:18:39 PM6/3/08
to Insoshi
I was able to rake install using sqlite on a windows vista machine but
not MySQL which was what I was hoping to use.
Michael, is there anyway you can post your database.yml so i can see
if i'm missing anything?

-steven

On May 20, 2:52 pm, "Michael Hartl" <mich...@insoshi.com> wrote:
> Strange. Is anyone else having this problem? Let us know if you find
> a solution.
>
> Michael
>
> On Tue, May 20, 2008 at 12:04 PM, Kless <jonas....@googlemail.com> wrote:
>
> > I got *94 failures* withMySQLv5.0.51 on Ubuntu Hardy, x86_64

Michael Hartl

unread,
Jun 3, 2008, 11:15:28 PM6/3/08
to ins...@googlegroups.com
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
# development:
# adapter: sqlite3
# database: db/development.sqlite3
# timeout: 5000
development:
adapter: mysql
database: insoshi_development
username: root
password:
timeout: 5000

# Warning: The database defined as 'test' will be erased and
# re-generated from your development database when you run 'rake'.
# Do not set this db to the same as development or production.
test:
adapter: mysql

database: insoshi_test
username: root
password:
timeout: 5000

megatoast

unread,
Jun 7, 2008, 12:10:23 AM6/7/08
to Insoshi
any ideas what's wrong with my rake install for MySQL?

_______________
>(in C:/Workspace/insoshiMySQL)
** Invoke install (first_time)
** Invoke environment (first_time)
** Execute environment
rake install
** Execute install
** Invoke db:migrate (first_time)
** Invoke environment
** Execute db:migrate
rake aborted!
NULL pointer given
(eval):3:in `each_hash'
(eval):3:in `all_hashes'
C:/Workspace/insoshiMySQL/vendor/rails/activerecord/lib/active_record/
connection_adapters/mysql_adapter.rb:482:in `select_without_analyzer'
C:/Workspace/insoshiMySQL/vendor/plugins/query_analyzer/lib/
query_analyzer.rb:44:in `select'
C:/Workspace/insoshiMySQL/vendor/rails/activerecord/lib/../../
activesupport/lib/active_support/buffered_logger.rb:25:in `silence'
C:/Workspace/insoshiMySQL/vendor/plugins/query_analyzer/lib/
query_analyzer.rb:42:in `select'
C:/Workspace/insoshiMySQL/vendor/rails/activerecord/lib/active_record/
connection_adapters/abstract/database_statements.rb:7:in
`select_all_without_query_cache'
C:/Workspace/insoshiMySQL/vendor/rails/activerecord/lib/active_record/
connection_adapters/abstract/query_cache.rb:55:in `select_all'
C:/Workspace/insoshiMySQL/vendor/rails/activerecord/lib/active_record/
connection_adapters/abstract/database_statements.rb:13:in `select_one'
C:/Workspace/insoshiMySQL/vendor/rails/activerecord/lib/active_record/
connection_adapters/abstract/database_statements.rb:19:in
`select_value'
C:/Workspace/insoshiMySQL/vendor/rails/activerecord/lib/active_record/
migration.rb:319:in `current_version'
C:/Workspace/insoshiMySQL/vendor/rails/activerecord/lib/active_record/
migration.rb:335:in `current_version'
C:/Workspace/insoshiMySQL/vendor/rails/activerecord/lib/active_record/
migration.rb:414:in `irrelevant_migration?'
C:/Workspace/insoshiMySQL/vendor/rails/activerecord/lib/active_record/
migration.rb:345:in `migrate'
C:/Workspace/insoshiMySQL/vendor/rails/activerecord/lib/active_record/
migration.rb:339:in `each'
C:/Workspace/insoshiMySQL/vendor/rails/activerecord/lib/active_record/
migration.rb:339:in `migrate'
C:/Workspace/insoshiMySQL/vendor/rails/activerecord/lib/active_record/
migration.rb:307:in `up'
C:/Workspace/insoshiMySQL/vendor/rails/activerecord/lib/active_record/
migration.rb:298:in `migrate'
C:/Workspace/insoshiMySQL/vendor/rails/railties/lib/tasks/
databases.rake:85
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in
`invoke_with_call_chain'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in
`synchronize'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in
`invoke_with_call_chain'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke'
C:/Workspace/insoshiMySQL/lib/tasks/install.rake:7
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:544:in `call'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:544:in `execute'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in
`invoke_with_call_chain'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in
`synchronize'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in
`invoke_with_call_chain'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in
`invoke_task'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in
`top_level'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in
`top_level'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in
`standard_exception_handling'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in
`top_level'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in
`standard_exception_handling'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31
c:/ruby/bin/rake:19:in `load'
c:/ruby/bin/rake:19

___________________

On Jun 3, 10:15 pm, "Michael Hartl" <mich...@insoshi.com> wrote:
> # SQLite version 3.x
> # gem install sqlite3-ruby (not necessary on OS X Leopard)
> # development:
> # adapter: sqlite3
> # database: db/development.sqlite3
> # timeout: 5000
> development:
> adapter: mysql
> database: insoshi_development
> username: root
> password:
> timeout: 5000
>
> # Warning: The database defined as 'test' will be erased and
> # re-generated from your development database when you run 'rake'.
> # Do not set this db to the same as development or production.
> test:
> adapter: mysql
> database: insoshi_test
> username: root
> password:
> timeout: 5000
>

megatoast

unread,
Jun 7, 2008, 2:26:13 AM6/7/08
to Insoshi
AHHHHHHHHHHHHHHHHHHHHHH.

finally figured out the problem.

if you have the MySQL gem installed and a previous standalone MySQL
installation, that causes a conflict. I'm not sure why, but once i
uninstalled the gem, i was able to get rake going. hope this helps
anyone who's having problem with raking MySQL.

-steven

Long Nguyen

unread,
Jun 7, 2008, 3:13:24 PM6/7/08
to ins...@googlegroups.com
What was the previous version of MySQL?

Since the gem does do some native compilations, it's possible that the version mismatch between your old install and new install was the source of the errors.

Long
--
Long Nguyen
long....@insoshi.com

Michael Hartl

unread,
Jun 18, 2008, 4:46:00 PM6/18/08
to ins...@googlegroups.com
After a couple hours of agonizing confusion, I've discovered another
source of possible trouble with MySQL and Rails tests. If you use a
MySQL configuration file (my.cnf, which typically lives in
/etc/my.cnf), there is a section that says "Uncomment the following if
you are using InnoDB tables". If you do indeed uncomment that
section, to all appearances it works fine in the app, but it breaks a
bunch of tests. This might be because those lines only work if *all*
the tables are InnoDB, but the schema_info table used by the Rails
tests is MyISAM. That mismatch might be causing the problem. In any
case, avoiding a my.cnf file in your development/test environment is
the way to go.

Michael

--
Michael Hartl
Insoshi social software
http://insoshi.com/

Reply all
Reply to author
Forward
0 new messages