Jeremy- 

Updated gist: 
https://gist.github.com/6240781.git 



Down to 2 failing tests. Not sure how to fix these 2. 





Failures: 


1) RcteTree Plugin should not populate :children associations for final level 
when loading descendants to a given level 
Failure/Error: nodes[0].associations[:children].map{|c1| 
c1.associations[:children]}.should == [nil, nil] 
expected: [nil, nil] 
got: [[], []] (using ==) 
Diff: 
@@ -1,2 +1,2 @@ 
-[nil, nil] 
+[[], []] 
# ./spec/integration/plugin_test.rb:858:in `block (2 levels) in <top 
(required)>' 


I don't even know where to begin to figure out what is going on with this. Very 
complicated recursion sql is generated and looks valid (works in dbisql). 
Something to do with the eager method, maybe? Although all the other tests with 
eager are working. 


2) Database foreign key parsing should parse foreign key information into an 
array of hashes 
Failure/Error: @db.alter_table(:b){drop_foreign_key :e} 
Sequel::DatabaseError: 
Sequel::SqlAnywhere::SQLAnywhereException: Foreign key name 'A' not found 
# ./lib/sequel/database/misc.rb:402:in `raise_error' 
# ./lib/sequel/adapters/sqlanywhere.rb:97:in `block in execute_dui' 
# ./lib/sequel/database/connecting.rb:229:in `block in synchronize' 
# ./lib/sequel/connection_pool/threaded.rb:104:in `hold' 
# ./lib/sequel/database/connecting.rb:229:in `synchronize' 
# ./lib/sequel/adapters/sqlanywhere.rb:91:in `execute_dui' 
# ./lib/sequel/database/query.rb:43:in `execute_ddl' 
# ./lib/sequel/database/schema_methods.rb:377:in `block in apply_alter_table' 
# ./lib/sequel/database/schema_methods.rb:377:in `each' 
# ./lib/sequel/database/schema_methods.rb:377:in `apply_alter_table' 
# ./lib/sequel/database/schema_methods.rb:382:in `apply_alter_table_generator' 
# ./lib/sequel/extensions/constraint_validations.rb:283:in 
`apply_alter_table_generator' 
# ./lib/sequel/database/schema_methods.rb:78:in `alter_table' 
# ./spec/integration/schema_test.rb:227:in `block (2 levels) in <top 
(required)>' 


This one is 2 fold: 
1) SqlAnywhere will not allow you to add or drop a column or a foreign key if 
if violates a uniqueness constraint. So, before adding/dropping I query the 
schema to see if I need to do something i.e. alter the column to not be null if 
it is going to be a foreign key in another table. So, I made the appropriate 
alter_table_sql to do so to get these tests to work. In doing so, I cause the 
above to happen because this statement: 

@db.alter_table(:b){drop_foreign_key :e} 


generates 2 identical ALTER TABLE statements in the operations list of: 


ALTER TABLE B DROP FOREIGN KEY A 
ALTER TABLE B DROP FOREIGN KEY A 


Both are valid. The problem is the second will fail because of the first one 
removed the fk. I can add uniq to the return value of Sequel method 
alter_table_sql_list and it will work, but don't like that. If I remove the 
code that is generating the first ALTER TABLE, then I get a different test that 
fails which is dropping of a column that is used as a fk. Code that is 
generating the first ALTER TABLE: 



when :drop_column 
sqls = [] 
f_keys = foreign_key_list(table) 
constraint_names = f_keys.map{|h| h[:name] if h[:columns].include?(op[:name])} 
constraint_names.each do |constraint| 
sqls << alter_table_sql(table, {:op => :drop_constraint, :type => :foreign_key, 
:name => constraint}) <---------- right here. 
end 
sqls << "ALTER TABLE #{quote_schema_table(table)} DROP 
#{column_definition_sql(op)}" 






2) I had to comment out this part of the test because I can not figure out what 
I need to do to prevent the constraint violation that it is causing. I think I 
have to add a uniqueness index for the composite key and I still can't figure 
out the ALTER TABLE SQL for that and have been trying the SqlAnyhere Sybase 
Central client program. Hopefully, I can figure that one out here soon. 


~line 220 of schema_test.rb 

#@db.alter_table(:a){add_index [:d, :c], :unique=>true} 
#@db.alter_table(:b){add_foreign_key [:f, :e], :a, :key=>[:d, :c]} 
#@pr[:b, [[:e], :a, [:pk, :c]], [[:f], :a, [:c]], [[:f], :a, [:d]], [[:f, :e], 
:a, [:d, :c]]] 


#@db.alter_table(:b){drop_foreign_key [:f, :e]} 
@pr[:b, [[:e], :a, [:pk, :c]], [[:f], :a, [:c]], [[:f], :a, [:d]]] 





Finished in 1 minute 2.32 seconds 
519 examples, 2 failures, 7 pending 


Failed examples: 


rspec ./spec/integration/plugin_test.rb:855 # RcteTree Plugin should not 
populate :children associations for final level when loading descendants to a 
given level 
rspec ./spec/integration/schema_test.rb:208 # Database foreign key parsing 
should parse foreign key information into an array of hashes 








The pending ones are with reasons: 

Pending: 
Sequel::Database should provide ability to check connections for validity 
# Not yet working on sqlanywhere 
# ./spec/integration/spec_helper.rb:75 


It looks like the sqlanywhere native gem acts just like the sybase client 
software dbisql and sybase central where if you disconnect and then issue an 
SQL statement it auto reconnects you to your last connection sending back the 
results. 



Simple dataset operations with nasty table names should work correctly 
# Not yet working on sqlanywhere 
# ./spec/integration/spec_helper.rb:75 

Sequel::Database should correctly escape multiple backslash strings 
# Not yet working on sqlanywhere 
# ./spec/integration/spec_helper.rb:75 
Sequel::Database should properly escape identifiers 
# Not yet working on sqlanywhere 
# ./spec/integration/spec_helper.rb:75 
Sequel::Dataset DSL support should work with bitwise shift operators 
# Not yet working on sqlanywhere 
# ./spec/integration/spec_helper.rb:75 
Bound Argument Types should handle blob type with embedded zeros 
# Not yet working on sqlanywhere 
# ./spec/integration/spec_helper.rb:75 
Supported types should support generic file type 
# Not yet working on sqlanywhere 
# ./spec/integration/spec_helper.rb:75 


All of these have to do with escaping characters and the native sqlanywhere gem 
use of StringValueCStr and there is no other method to call that does not use 
that on the sql string that is passed in. I split the escape backslash strings 
into 2 tests. On that worked for sqlanywhere and the ones that did not putting 
them into a cspecify. I called it escape multiple backslash strings. 


I can set up a JDBC sqlanyhere adapter. That should not take too long to do and 
see if these can pass. 




Thanks, 


-GregD 









-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to