aaron3481 / assql

Automatically exported from code.google.com/p/assql
0 stars 0 forks source link

Type coercion error when using MySqlService #71

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Attempting to use MySqlService and providing invalid authentication

What is the expected output? What do you see instead?
The following error is thrown:

TypeError: Error #1034: Type Coercion failed: cannot convert
flash.events::ErrorEvent@d959fc1 to com.sql.mysql.events.MySqlErrorEvent.
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at
com.sql.mysql::MySqlService/handleConnectError()[/Users/arek/Documents/Flex
Builder 3/SQLDE/src/com/sql/mysql/MySqlService.as:179]

What version of the product are you using? On what operating system?
Flex Builder (SDK 3.2) w/ AIR 1.5 on Mac OS X 10.5.6

Please provide any additional information below.

Its possible i screwed up somewhere, but I did however solve the problem by
changing line 179 in the MySqlService.as file,

From: dispatchEvent(e);
To: dispatchEvent(new MySqlErrorEvent(e.msg, e.id));

Original issue reported on code.google.com by beuker.m...@gmail.com on 20 Jan 2009 at 8:49

GoogleCodeExporter commented 9 years ago
I've been looking the code because I had the same problem as you, and found 
what is
causing this. Another error was also thrown:

TypeError: Error #1034: Type Coercion failed: cannot convert
com.maclema.mysql.events::MySqlErrorEvent@1e22f71 to 
com.maclema.mysql.events.MySqlEvent.
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at
com.maclema.mysql::MySqlService/handleConnectError()[C:\workspaces\pixeltree\MyT
est\src\com\maclema\mysql\MySqlService.as:182]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at
ErrorHandler()[C:\workspaces\pixeltree\MyTest\src\com\maclema\mysql\ErrorHandler
.as:18]

I've modified the code for correcting these issues as this:

com.maclema.mysql.mxml.MySqlService

line 91:
    private function removeBusyCursor(e:MySqlEvent=null):void {

changed to:
    private function removeBusyCursor(e:Event=null):void {

The listener was expecting an event with the type MySqlEvent, but as we can see 
on
the constructor for the class, this method is registered as listener for 3 
types of
event:
    addEventListener(MySqlErrorEvent.SQL_ERROR, removeBusyCursor);
    addEventListener(MySqlEvent.RESULT, removeBusyCursor);
    addEventListener(MySqlEvent.RESPONSE, removeBusyCursor);
    addEventListener(Event.CLOSE, removeBusyCursor);

The other error, reported by beuker.marcel, was corrected adding a clone() 
method for
the class MySqlErrorEvent:

    override public function clone():Event {
         return new MySqlErrorEvent(msg, id);
    }

Because the clone method wasn't overriden, it was returning an object from its
superclass type, ErrorEvent, instead of the expected MySqlErrorEvent.

Sorry for any english mistake :)

Original comment by pablotor...@gmail.com on 26 Mar 2009 at 12:35

GoogleCodeExporter commented 9 years ago
Excellent work.  My solution was good enought for me at the time and I never 
looked
much further into it, but your solution is proper.  Thanks

Original comment by beuker.m...@gmail.com on 26 Mar 2009 at 12:47

GoogleCodeExporter commented 9 years ago
I've added the override to the clone method that Pablo suggested. In the 
subversion
code the RemoveBusyCursor function had already been changed to accept anything 
(e:* =
null). I've also changed the MySqlEvent class so that it has the correct 
overrides
for the clone() and toString() methods.

Original comment by celeryn...@gmail.com on 24 May 2009 at 4:23

GoogleCodeExporter commented 9 years ago
Committed to subversion rev 178

Original comment by celeryn...@gmail.com on 24 May 2009 at 9:19

GoogleCodeExporter commented 9 years ago

Original comment by celeryn...@gmail.com on 24 May 2009 at 9:25