Skip to content

Commit

Permalink
Accept symbol as a column name and type
Browse files Browse the repository at this point in the history
  • Loading branch information
tomykaira committed Mar 17, 2012
1 parent 8e97554 commit 02c9e34
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/fusion_tables/ext/fusion_tables.rb
Expand Up @@ -50,6 +50,9 @@ def create_table(table_name, columns)

# ensure all column types are valid
columns.each do |col|
col[:name] = col[:name].to_s
col[:type] = col[:type].to_s

if !DATATYPES.include? col[:type].downcase
raise ArgumentError, "Ensure input types are: 'number', 'string', 'location' or 'datetime'"
end
Expand Down
7 changes: 7 additions & 0 deletions test/test_ext.rb
Expand Up @@ -24,6 +24,13 @@ class TestExt < Test::Unit::TestCase
assert_equal GData::Client::FusionTables::Table, @table.class
end

should "accept symbol for name and type" do
@table = @ft.create_table "test_table", [{:name => :test_col, :type => :string }]
first_column = @table.describe[0]
assert_equal 'test_col', first_column[:name]
assert_equal 'string', first_column[:type]
end

should "correct your table name to a certain degree on create" do
@table = @ft.create_table "test table", [{:name => "test col", :type => "string" }]
assert_equal "test_table", @table.name
Expand Down

0 comments on commit 02c9e34

Please sign in to comment.