Giter Site home page Giter Site logo

dm-oracle-adapter's People

Contributors

capoferro avatar dbussink avatar dkubb avatar dsisnero avatar emmanuel avatar namelessjon avatar rsim avatar sam avatar snusnu avatar solnic avatar tillsc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dm-oracle-adapter's Issues

Problems with jdbc URIs

OJDBC needs URIs in form of:

 jdbc:oracle:thin:@[Host][:Port]/SID

The Problem is the @character in the URIs which is required in the ODJBC URIs. It is present in the URI if you specify a Host.

Examples (JDBC-URI visible by accessing the do_jdbc Connection directly):

DataMapper.setup(:default, {:adapter => "oracle", :database => "MY_SID"})
# => JdbcURI: "jdbc:oracle:thin:MY_SID" (lacking the "@")

DataMapper.setup(:default, {:adapter => "oracle", :database => "@MY_SID"})
# => JdbcURI: "jdbc:oracle:thin:@MY_SID" (Yay!)

The last Hack seems to do the trick, BUT DataMapper seems to find the "@" in it's internal DM-URI and is assuming the credentials are already specified somewhere else. So it will ignore the :username and :password parameters seen in the following example:

DataMapper.setup(:default, {:adapter => "oracle", :database => "@MY_SID", :username => "SCOTT", :password => "TIGER"})
# No Username and password arriving in do_jdbc Connection

DataMapper.setup(:default, {:adapter => "oracle", :database => "SCOTT/TIGER@MY_SID"})
# Works! But I hate it :-)

For completeness reasons the jdbc URI with :host parameter:

DataMapper.setup(:default, {:adapter => "oracle", :database => "MY_SID", :host => "localhost", :username => "SCOTT", :password => "TIGER"})
# => JdbcURI: "jdbc:oracle:thin:@//localhost/MY_SID" (looks a bit strange but works)

TNSNAMES.ora location with ojdbc

When you want ojdbc to use a database specified in TNSNAMES.ora you'll have to specify the location of the TNSNAMES.ora file:

if RUBY_PLATFORM =~ /java/
  java.lang.System.setProperty("oracle.net.tns_admin", "/opt/oracle/network/admin") 
end

This must be done in the application somewhere.

AFAIK @rsim's oracle-enhanced adapter for ActiveRecord is doing this in the adapter by looking at an environment variable called "TNS_ADMIN" (which is used by sqlplus to locate the TNSNAMES.ora).

`require': cannot load such file -- oci8 (LoadError)

I'm running ruby 2.0 on Mac,

here's the Gemfile:

gem 'sinatra'
gem 'thin'
~ #gem 'dm-postgres-adapter'

  • gem 'dm-oracle-adapter'
    gem 'dm-core'
    gem 'json'
    gem 'haml'
    gem 'dm-serializer'
  • gem 'sinatra-websocket'
    group :development do
    gem 'pry'
    gem 'haml'
    gem 'dm-migrations'
    end

and because I couldn't find README file I setup like this:

DataMapper.setup(:default, 'oracle://system:manager@localhost:1521/XE')

Model.get(id) is not working

Hi,

I'm using DataMapper and dm-oracle-adapter. I have a table at Oracle like this:


 ID_ICON              NOT NULL NUMBER(3)
 ICON_PT              VARCHAR2(200)
 STATUS                NUMBER(1)

ID_ICON is the Primary Key.

So, I have a model like this:


class Icon

  include DataMapper::Resource

  storage_names[:default] = "icon"

  property :id, Serial, :field => 'id_icon'

  property :icon_pt, String
  property :icon_es, String
  property :icon_en, String
  property :status, Integer

end

Supose that I have a registry at this table with ID 1. When I try to find it, like this:

@icon = Icon.get(1)

It simply can't find that record!

But the record is there:


Icon.all
 => [#<Icon @id=1 @icon_pt="a" @icon_es="b" @icon_en="c" @status=2>] 

This is the query that the server is doing:

SQL (3.920ms)  SELECT "ID_ICON", "ICON_PT", "ICON_ES", "ICON_EN", "STATUS" FROM "ICON" WHERE ("ID_ICON" = :1) AND rownum <= :2

What Am I missing?

Thank you in advance.

Using empty string in conditions gives incorrect results

Hi,

I found a (known) problem with Oracle and was asked in the Datamapper IRC channel to report it here. Even though it's Oracle at fault, perhaps you could create a work-around for it.

Here's an example of the issue demonstrated in the Ruby console:

irb(main):011:0* Item.count
=> 76
irb(main):012:0> Item.count(:serial => 'asdf')
=> 1
irb(main):013:0> Item.count(:serial.not => 'asdf')
=> 75
irb(main):014:0> Item.count(:serial => '')
=> 0
irb(main):015:0> Item.count(:serial.not => '')
=> 0

As you can see, counting the records works when a proper string is specified. However, when the string is empty the count is always 0. As this is not a problem with Datamapper, it can be reproduced with SQL as well. Here's an example:

SQL> select count() from items;
76
SQL> select count(
) from items where serial='asdf';
1
SQL> select count() from items where not(serial='asdf');
75
SQL> select count(
) from items where serial='';
0
SQL> select count(*) from items where not(serial='');
0

Using != or <> works the same way.

The database version is Oracle Database 10g Release 10.2.0.1.0 - 64bit Production, but this is probably an issue with other versions as well. The problem exists in other finder methods as well, such as .all. The problem stems from Oracle treating an empty string as null. Googling reveals more information: http://www.google.com/search?q=oracle+empty+string+null

order by is not working with conditions

Consider this:

  class Post
    include DataMapper::Resource
    property :id, Serial
    property :user_id, Integer
    property :created_at, Time
  end

    Post.all(:user_id => 123, :order => [:created_at]).to_a

The generated sql will look like this:

  SELECT "ID", "USER_ID", "CREATED_AT" FROM "POSTS" WHERE ("USER_ID" = :1)

The order by clause has gone missing.

Here is what I'm able to track down:

At https://github.com/datamapper/dm-oracle-adapter/blob/master/lib/dm-oracle-adapter/adapter.rb#L121

no_order is set to true and the thus the order by clause is never generated.

I don't fully understand

https://github.com/datamapper/dm-oracle-adapter/blob/master/lib/dm-oracle-adapter/adapter.rb#L108

and

https://github.com/datamapper/dm-oracle-adapter/blob/master/lib/dm-oracle-adapter/adapter.rb#L117

But from the comment, I think it is only for some special cases where only one record is needed?

If you could help me understand what those two conditional statements mean, I don't mind working on a fix for this.

Thanks!

AQ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.