Changeset 199

Show
Ignore:
Timestamp:
09/10/06 22:24:56 (2 years ago)
Author:
sandal
Message:

:origin is now optional

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/ruport/query.rb

    r101 r199  
    6060    # 
    6161    #   # uses a SQL file stored on disk 
    62     #   Ruport::Query.new("my_query.sql",:origin => :file) 
     62    #   Ruport::Query.new("my_query.sql") 
     63    # 
     64    #   # explicitly use a file, even if it doesn't end in .sql 
     65    #   Ruport::Query.new("foo",:origin => :file) 
    6366    def initialize(sql, options={}) 
    6467      options = { :source => :default, :origin => :string }.merge(options) 
    65       @sql = sql 
     68      options[:origin] = :file if sql =~ /.sql$/ 
    6669      @statements = SqlSplit.new(get_query(options[:origin],sql)) 
     70      @sql = @statements.join 
    6771       
    6872      if options[:dsn] 
  • trunk/test/test_query.rb

    r112 r199  
    2020    assert_equal([[1,2,3],[4,5,6],[7,8,9]],@query1.result) 
    2121  end 
     22 
     23  def test_auto_resolve_file 
     24    q = Ruport::Query.new "test/samples/query_test.sql" 
     25    assert_equal "select * from foo", q.sql 
     26  end 
     27 
    2228   
    2329  def test_each 
     
    6268  end 
    6369 
    64   def test_to_dataset 
    65     # query needs to be re-worked for a test like this 
    66     # to be written 
    67   end 
    68  
    6970  def test_caching_triggers 
    7071    assert_nothing_raised { @query1.enable_caching } 
  • trunk/test/test_report.rb

    r197 r199  
    4242    } 
    4343    assert_equal "a,b,c\n1,2,3\n4,5,6\n7,8,9\n",  
    44        @report.query("blah",:query_obj => @query1, :as => :csv) 
     44       @report.query("blah",:query_obj => @query1, :as => :csv)        
    4545  end 
    4646