Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with database link #140

Closed
dimakura opened this issue Jan 9, 2012 · 4 comments
Closed

Problem with database link #140

dimakura opened this issue Jan 9, 2012 · 4 comments

Comments

@dimakura
Copy link

dimakura commented Jan 9, 2012

Problem

Given a class:

class Customer < ActiveRecord::Base
  set_table_name 'customer@programmer'
  set_primary_key :custkey
end

when a simple finder is executed:

Customer.find(1)

the following error is thrown:

NativeException: java.sql.SQLSyntaxErrorException:
ORA-02084: database name is missing a component:
SELECT  "CUSTOMER"@"PROGRAMMER".* FROM "CUSTOMER"@"PROGRAMMER"
WHERE "CUSTOMER"@"PROGRAMMER"."CUSTKEY" = :a1 AND ROWNUM <= 1

Possible resolution

Instead of:

SELECT  "CUSTOMER"@"PROGRAMMER".* FROM "CUSTOMER"@"PROGRAMMER"
WHERE "CUSTOMER"@"PROGRAMMER"."CUSTKEY" = :a1 AND ROWNUM <= 1

should be written:

SELECT  "CUSTOMER".* FROM "CUSTOMER"@"PROGRAMMER"
WHERE "CUSTOMER"."CUSTKEY" = :a1 AND ROWNUM <= 1
@westlakem
Copy link

Why has nothing been done on this?

@openface
Copy link
Contributor

Maybe submit a pull request?

@yahonda
Copy link
Collaborator

yahonda commented Jul 29, 2015

How about adding a synonym to the table over the db link.

Based on unit tests , I think it should work.

https://github.com/rsim/oracle-enhanced/blob/master/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb#L1009-L1013

    before(:each) do
      class ::TestPost < ActiveRecord::Base
        self.table_name = "synonym_to_posts"
      end
    end

https://github.com/rsim/oracle-enhanced/blob/master/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb#L1035-L1044

    it "should create synonym to table over database link" do
      db_link = @db_link
      schema_define do
        add_synonym :synonym_to_posts, "test_posts@#{db_link}", :force => true
        add_synonym :synonym_to_posts_seq, "test_posts_seq@#{db_link}", :force => true
      end
      lambda do
        TestPost.create(:title => "test")
      end.should_not raise_error
    end

@yahonda
Copy link
Collaborator

yahonda commented Oct 12, 2015

Closing this issue since no feedback available.

@yahonda yahonda closed this as completed Oct 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants