Bugs: Browse | Submit New | Admin

[#29653] Namespace collision - class Mysql::Time and Ruby Time class

Date:
2012-10-04 22:00
Priority:
3
Submitted By:
Jonathan Seder (jds13)
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
Namespace collision - class Mysql::Time and Ruby Time class

Detailed description
Mysql defines a Mysql::Time subclass.  Unfortunately, this creates a namespace collision when application extensions
to the Mysql class invoke system Time class methods.  The following code generates this error message:
   undefined method `now' for Mysql::Time:Class

class Mysql
   def timed_query(qs)
      t0 = Time.now
      qq = self.query(qs)
      t1 = Time.now()
      printf("\nLong query (%.1f): %s",(t1-t0),qs) if (t1-t0)>1.0
      qq
      end
   end

It would be nice if the Mysql::Time class could be renamed Mysql::MysqlTime.  And if there's an elegant solution to
this problem I'd be grateful to be taught.  I've resorted to a hack of wrapping Time inside a new class with new method
names.

Thank you.

Add A Comment: Notepad

Please login


Followup

No Followups Have Been Posted

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item