Permalink
Browse files

Adds method to rename existing tables

  • Loading branch information...
1 parent c59f211 commit 5f81111515451dfb25b2dba961b86f036680961d @Ferdev Ferdev committed May 7, 2012
@@ -68,6 +68,20 @@ def create_table(table_name = nil, schema_or_file = nil, the_geom_type = 'Point'
end
+ def rename_table(old_table_name, new_table_name)
+ request = cartodb_request "tables/#{old_table_name}",
+ :put,
+ :params => {
+ :name => new_table_name
+ } do |response|
+ return Utils.parse_json(response)
+ end
+
+ execute_queue
+
+ request.handled_response
+ end
+
def add_column(table_name, column_name, column_type)
cartodb_request "tables/#{table_name}/columns",
:post,
@@ -34,6 +34,7 @@ def setup_point_geometry
self.send :define_method, :latitude do
self.the_geom ? self.the_geom.y : nil
end
+
self.send :define_method, :longitude do
self.the_geom ? self.the_geom.x : nil
end
View
@@ -115,6 +115,15 @@
table.schema.should include(["the_geom", "geometry", "geometry", "multipolygon"])
end
+ it "should rename an existing table" do
+ table = CartoDB::Connection.create_table 'cartodb_spec'
+
+ table.name.should be == 'cartodb_spec'
+
+ table = CartoDB::Connection.rename_table 'cartodb_spec', 'renamed_cartodb_spec'
+ table.name.should be == 'renamed_cartodb_spec'
+ end
+
it "should create a table with MULTILINESTRING type geometry" do
table = CartoDB::Connection.create_table 'cartodb_spec', 'multilinestring'

0 comments on commit 5f81111

Please sign in to comment.