Discussion:
ErlyDB without ErlyWeb problem with reversed params
Jake Morrison
2008-01-09 12:47:15 UTC
Permalink
Hi,

I am trying to get erlydb running outside of erlyweb. So I tried to run the
test/erlydb/erlydb_test.erl program. It's not working, though. I had to
swap around the parameters on the code_gen call. So it obviously hasn't
been run since things changed in 0.7.

After that change, it runs for a while, but fails later on. Something is
going wrong with the code gen, I guess, as the order of the parameters
is not matching up in the generated SQL.

before save: {developer,true,undefined,<<"Joe Armstrong">>,<<"Sweden">>}
mysql_conn:426: fetch <<"BEGIN">> (id <0.41.0>)
mysql_conn:426: fetch <<"INSERT INTO person(type,name,country) VALUES
('developer','Sweden','Joe Armstrong')">> (id <0.41.0>)
mysql_conn:426: fetch <<"SELECT last_insert_id()">> (id <0.41.0>)
mysql_conn:426: fetch <<"COMMIT">> (id <0.41.0>)

So a 'developer' is getting created like
developer:new(<<"Joe Armstrong">>, <<"Sweden">>)
But when it is inserted into the table, the name and country are reversed.

The fields() are defined in developer.erl as [name, country].

Any ideas what's going wrong?

Thanks,
Yariv Sadan
2008-01-10 08:19:36 UTC
Permalink
I haven't actually ran this test code in a while so it could be
broken. What DBMS are you using?

Btw, it should be quite easy to use ErlyDB without ErlyWeb. Just call
erlydb:start() followed by erlydb:code_gen().

Yariv
Post by Jake Morrison
Hi,
I am trying to get erlydb running outside of erlyweb. So I tried to run the
test/erlydb/erlydb_test.erl program. It's not working, though. I had to
swap around the parameters on the code_gen call. So it obviously hasn't
been run since things changed in 0.7.
After that change, it runs for a while, but fails later on. Something is
going wrong with the code gen, I guess, as the order of the parameters
is not matching up in the generated SQL.
before save: {developer,true,undefined,<<"Joe Armstrong">>,<<"Sweden">>}
mysql_conn:426: fetch <<"BEGIN">> (id <0.41.0>)
mysql_conn:426: fetch <<"INSERT INTO person(type,name,country) VALUES
('developer','Sweden','Joe Armstrong')">> (id <0.41.0>)
mysql_conn:426: fetch <<"SELECT last_insert_id()">> (id <0.41.0>)
mysql_conn:426: fetch <<"COMMIT">> (id < 0.41.0>)
So a 'developer' is getting created like
developer:new(<<"Joe Armstrong">>, <<"Sweden">>)
But when it is inserted into the table, the name and country are reversed.
The fields() are defined in developer.erl as [name, country].
Any ideas what's going wrong?
Thanks,
Jake (Reach on freenode)
j***@public.gmane.org
2008-01-10 09:55:12 UTC
Permalink
Hi Yariv,
Post by Yariv Sadan
I haven't actually ran this test code in a while so it could be
broken. What DBMS are you using?
The same error occurs with both MySQL and PostgreSQL. The error
message that I posted came from MySQL. I plan
to use it with PostgreSQL, though.
Post by Yariv Sadan
Btw, it should be quite easy to use ErlyDB without ErlyWeb. Just call
erlydb:start() followed by erlydb:code_gen().
I am just getting started, so I figured I would start by running the
tests.

Is there a complete example somewhere that I could start with
instead?
Post by Yariv Sadan
Yariv
Thanks,
Jake
Post by Yariv Sadan
Post by Jake Morrison
Hi,
I am trying to get erlydb running outside of erlyweb. So I tried to run the
test/erlydb/erlydb_test.erl program. It's not working, though. I had to
swap around the parameters on the code_gen call. So it obviously hasn't
been run since things changed in 0.7.
After that change, it runs for a while, but fails later on. Something is
going wrong with the code gen, I guess, as the order of the parameters
is not matching up in the generated SQL.
before save: {developer,true,undefined,<<"Joe Armstrong">>,<<"Sweden">>}
mysql_conn:426: fetch <<"BEGIN">> (id <0.41.0>)
mysql_conn:426: fetch <<"INSERT INTO person(type,name,country) VALUES
('developer','Sweden','Joe Armstrong')">> (id <0.41.0>)
mysql_conn:426: fetch <<"SELECT last_insert_id()">> (id <0.41.0>)
mysql_conn:426: fetch <<"COMMIT">> (id < 0.41.0>)
So a 'developer' is getting created like
developer:new(<<"Joe Armstrong">>, <<"Sweden">>)
But when it is inserted into the table, the name and country are reversed.
The fields() are defined in developer.erl as [name, country].
Any ideas what's going wrong?
Thanks,
Jake (Reach on freenode)
ngocdaothanh
2009-04-26 10:34:15 UTC
Permalink
The line:
lists:usort(DefinedFields)
in erlydb.erl, function get_db_fields breaks the order of return value
from fields().

Afer removing usort, all tests pass. I have only tested with Postgres.

Ngoc.
Post by j***@public.gmane.org
Hi Yariv,
Post by Yariv Sadan
I haven't actually ran this test code in a while so it could be
broken. What DBMS are you using?
The same error occurs with bothMySQLandPostgreSQL. The error
message that I posted came fromMySQL. I plan
to use it withPostgreSQL, though.
Post by Yariv Sadan
Btw, it should be quite easy to use ErlyDB without ErlyWeb. Just call
erlydb:start() followed by erlydb:code_gen().
I am just getting started, so I figured I would start by running the
tests.
Is there a complete example somewhere that I could start with
instead?
Post by Yariv Sadan
Yariv
Thanks,
Jake
Post by Yariv Sadan
Post by Jake Morrison
Hi,
I am trying to get erlydb running outside of erlyweb. So I tried to run the
test/erlydb/erlydb_test.erl program. It's not working, though. I had to
swap around the parameters on the code_gen call. So it obviously hasn't
been run since things changed in 0.7.
After that change, it runs for a while, but fails later on. Something is
going wrong with the code gen, I guess, as the order of the parameters
is not matching up in the generated SQL.
  before save: {developer,true,undefined,<<"Joe Armstrong">>,<<"Sweden">>}
  mysql_conn:426: fetch <<"BEGIN">> (id <0.41.0>)
  mysql_conn:426: fetch <<"INSERT INTO person(type,name,country) VALUES
    ('developer','Sweden','Joe Armstrong')">> (id <0.41.0>)
  mysql_conn:426: fetch <<"SELECT last_insert_id()">> (id <0.41.0>)
  mysql_conn:426: fetch <<"COMMIT">> (id < 0.41.0>)
So a 'developer' is getting created like
developer:new(<<"Joe Armstrong">>, <<"Sweden">>)
But when it is inserted into the table, the name and country are reversed.
The fields() are defined in developer.erl as [name, country].
Any ideas what's going wrong?
Thanks,
Jake (Reach on freenode)
Loading...