revert constant moves

pull/7250/head
Guido Fioravantti 9 years ago
parent 215dd15955
commit 28cbbcf055

@ -39,6 +39,9 @@ class Table
# See http://www.postgresql.org/docs/9.3/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
PG_IDENTIFIER_MAX_LENGTH = 63
# @see services/importer/lib/importer/column.rb -> RESERVED_WORDS
# @see config/initializers/carto_db.rb -> RESERVED_COLUMN_NAMES
RESERVED_COLUMN_NAMES = %w(oid tableoid xmin cmin xmax cmax ctid ogc_fid).freeze
PUBLIC_ATTRIBUTES = {
:id => :id,
:name => :name,
@ -857,8 +860,7 @@ class Table
end
def add_column!(options)
raise CartoDB::InvalidColumnName if Carto::DB::Sanitize::RESERVED_COLUMN_NAMES.include?(options[:name]) ||
options[:name] =~ /^[0-9]/
raise CartoDB::InvalidColumnName if RESERVED_COLUMN_NAMES.include?(options[:name]) || options[:name] =~ /^[0-9]/
type = options[:type].convert_to_db_type
cartodb_type = options[:type].convert_to_cartodb_type
column_name = options[:name].to_s.sanitize_column_name
@ -913,9 +915,7 @@ class Table
raise 'Please provide a column name' if new_name.empty?
raise 'This column cannot be renamed' if CARTODB_COLUMNS.include?(old_name.to_s)
if new_name =~ /^[0-9]/ ||
Carto::DB::Sanitize::RESERVED_COLUMN_NAMES.include?(new_name) ||
CARTODB_COLUMNS.include?(new_name)
if new_name =~ /^[0-9]/ || RESERVED_COLUMN_NAMES.include?(new_name) || CARTODB_COLUMNS.include?(new_name)
raise CartoDB::InvalidColumnName, 'That column name is reserved, please choose a different one'
end

@ -18,6 +18,8 @@ module CartoDB
SURROGATE_NAMESPACE_PUBLIC_PAGES = 'rp'
SURROGATE_NAMESPACE_VIZJSON = 'rj'
RESERVED_COLUMN_NAMES = %w(FORMAT CONTROLLER ACTION oid tableoid xmin cmin xmax cmax ctid ogc_fid).freeze
LAST_BLOG_POSTS_FILE_PATH = "#{Rails.root}/public/system/last_blog_posts.html"
# Helper method to encapsulate Rails full URL generation compatible with our subdomainless mode

@ -189,8 +189,8 @@ class String
temporal_name = sanitize || ''
if temporal_name !~ /^[a-zA-Z_]/ ||
Carto::DB::Sanitize::RESERVED_WORDS.include?(downcase) ||
Carto::DB::Sanitize::RESERVED_COLUMN_NAMES.include?(downcase)
Carto::DB::Sanitize::RESERVED_WORDS.include?(downcase) ||
CartoDB::RESERVED_COLUMN_NAMES.include?(self.upcase)
return '_' + temporal_name
else
temporal_name

@ -13,7 +13,6 @@ module Carto
SYSTEM_TABLE_NAMES = %w(spatial_ref_sys geography_columns geometry_columns raster_columns raster_overviews
cdb_tablemetadata geometry raster).freeze
RESERVED_TABLE_NAMES = %w(layergroup all public).freeze
RESERVED_COLUMN_NAMES = %w(format controller action oid tableoid xmin cmin xmax cmax ctid ogc_fid).freeze
RESERVED_WORDS = %w(all analyse analyze and any array as asc asymmetric authorization between binary both
case cast check collate column constraint create cross current_date current_role
current_time current_timestamp current_user default deferrable desc distinct do else

Loading…
Cancel
Save