Uploaded image for project: 'CUBRID APIs'
  1. CUBRID APIs
  2. APIS-683

[Ruby] The stmt.affected_rows doesn't work with INSERT/UPDATE/DELETE DML

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: Ruby 8.4.4.0002
    • Fix Version/s: Ruby 8.4.4.0002
    • Component/s: Ruby Driver
    • Labels:
    • Environment:
      • Test OS: Linux 64
      • CUBRID: 8.4.4.0227
      • Ruby: 1.8.7
      • Driver: cubrid-ruby 8.4.4.0002 (2013-10-17)

      Description

      • The stmt.affected_rows throws an CUBRID:ERROR when work with INSERT/UPDATE/DELETE query
      • Test Code {code}
        con = Cubrid.connect('demodb','localhost',33000,'dba','')
        if con
        puts "connection established"
        con.query("DROP TABLE IF EXISTS test_cubrid")
        con.query("CREATE TABLE test_cubrid (id INT, name STRING)")

        stmt = con.query("INSERT INTO test_cubrid VALUES (1, 'Lily')")
        stmt = con.query("UPDATE test_cubrid set name = 'Lucy'")
        puts stmt.affected_rows
        con.close()
        else
        puts "Connection could not be established"
        end
        {code}

      Output

      [ruby@NC-PL-QA-012 other_test]$ ruby -rubygems test_affected_rows.rb 
      connection established
      test_affected_rows.rb:12:in `affected_rows': ERROR: CAS, -18, Invalid request handle (Cubrid::Error)
              from test_affected_rows.rb:12
      

        Activity

        Hide
        cn15800 谢韦华[Bert] added a comment -

        If command type is not query, driver will close request handle when query complete, so if user call stmt.affected_rows, a exception will be thrown by driver.

        {code}
        stmt = con.query("UPDATE test_cubrid set name = 'Lucy'") ----> Driver will close request handle
        puts stmt.affected_rows ----------> exception: Invalid request handle
        con.close(){code}
        Show
        cn15800 谢韦华[Bert] added a comment - If command type is not query, driver will close request handle when query complete, so if user call stmt.affected_rows, a exception will be thrown by driver. {code} stmt = con.query("UPDATE test_cubrid set name = 'Lucy'") ----> Driver will close request handle puts stmt.affected_rows ----------> exception: Invalid request handle con.close(){code}
        Hide
        cn15800 谢韦华[Bert] added a comment -

        fixed

        Show
        cn15800 谢韦华[Bert] added a comment - fixed
        Hide
        ryin005 Ray Yin added a comment -

        Added a test case for this issue

        RB-8.4.4

        [ruby@NC-PL-QA-012 _13_issues]$ svn ci --username cn14323 -m "[APIS-683]Added a case to test affected_rows for DML"
        Adding         _13_issues/bug_apis_683
        Adding         _13_issues/bug_apis_683/cases
        Adding         _13_issues/bug_apis_683/cases/bug_apis_683.rb
        Transmitting file data .
        Committed revision 35521.
        

        Case link: http://svn.bds.nhncorp.com/xdbms/cubridqa/branches/RB-8.4.4/interface/Ruby/qa_test/ruby/_13_issues/bug_apis_683/

        Show
        ryin005 Ray Yin added a comment - Added a test case for this issue RB-8.4.4 [ruby@NC-PL-QA-012 _13_issues]$ svn ci --username cn14323 -m "[APIS-683]Added a case to test affected_rows for DML" Adding _13_issues/bug_apis_683 Adding _13_issues/bug_apis_683/cases Adding _13_issues/bug_apis_683/cases/bug_apis_683.rb Transmitting file data . Committed revision 35521. Case link: http://svn.bds.nhncorp.com/xdbms/cubridqa/branches/RB-8.4.4/interface/Ruby/qa_test/ruby/_13_issues/bug_apis_683/
        Hide
        ryin005 Ray Yin added a comment -
        • Test OS: Linux 64, Windows 32
        • CUBRID: 8.4.4.0227
        • Ruby: 1.8.7
        • Driver: cubrid-ruby 8.4.4.0002 (2013-10-21)

        Test Result: Pass

        Close the issue

        Show
        ryin005 Ray Yin added a comment - Test OS: Linux 64, Windows 32 CUBRID: 8.4.4.0227 Ruby: 1.8.7 Driver: cubrid-ruby 8.4.4.0002 (2013-10-21) Test Result: Pass Close the issue

          People

          • Assignee:
            cn15800 谢韦华[Bert]
            Reporter:
            ryin005 Ray Yin
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: