Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1013619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:07:50+00:00 2026-05-16T10:07:50+00:00

With Rails/ActiveRecord 2.3.8 I’d like to do: AnyModel.connection.create_table( ‘temp_any_model’, temporary: true, id: false, options:

  • 0

With Rails/ActiveRecord 2.3.8 I’d like to do:

AnyModel.connection.create_table( 'temp_any_model', temporary: true, id: false, options: 'like any_model' )

But AR insists on adding “()” to the generated SQL even though the field list is blank since the table DDL is being cloned, thus resulting in e.g.:

ActiveRecord::StatementInvalid: Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') like any_model' at line 1: 
CREATE TEMPORARY TABLE `temp_any_model` () like any_model

Is there any way to coerce AR to generate this simple create tablenewlike existing statement?

Besides obviously connection.execute(string) ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T10:07:51+00:00Added an answer on May 16, 2026 at 10:07 am

    Nope. The parenthesis are hard coded in create_table:

    def create_table(table_name, options = {})
      # snipped ...
    
      create_sql = "CREATE#{' TEMPORARY' if options[:temporary]} TABLE "            
      create_sql << "#{quote_table_name(table_name)} ("                             
      create_sql << table_definition.to_sql                                         
      create_sql << ") #{options[:options]}"                                        
      execute create_sql        
    end
    

    There’s nothing wrong with using execute on a string literal; I would do that if you don’t feel like writing a quick patch.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm aware that I can check an ActiveRecord through the rails console but it
I've played around with ruby on rails' ActiveRecord::Migration class and I like how easy
How do I destroy all but the newest n records using Rails' ActiveRecord? I
I have a syntax question regarding the Rails 3 ActiveRecord::Base.connection.execute method and parameter that
Using Rails ActiveRecord, am wanting to calculate the time between two datetime fields within
I have an Rails ActiveRecord group query: a = Product.select(date(date) as date, count(id) as
I've added a before_create filter to one of my Rails ActiveRecord models and inside
I'm working with an older version of Rails and ActiveRecord that does not have
I'm trying to write a test for ActiveRecord - and Rails uses MiniTest for
All of my rails 3.2.2 ActiveRecord methods are being executed twice. I noticed that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.