shvyrev / air-activerecord

Automatically exported from code.google.com/p/air-activerecord
0 stars 0 forks source link

New schema not generating #1

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. checkout code.
2. clear your sqlite db?
3. try running Test

What is the expected output? What do you see instead?
Expecting Table to be created and app to start.

Seeing:
SQLError: 'Error #3115: SQL Error.', details:'No schema objects in database 
'main' were found.', 
operation:'schema'
    at flash.data::SQLConnection/internalLoadSchema()
    at flash.data::SQLConnection/loadSchema()
    at flight.db::DB$/getSchema()[/Users/seth/Flex/air-activerecorrd/src/flight/db/DB.as:62]
    at flight.db.activeRecord::TableCreator$/updateTable()[/Users/seth/Flex/air-
activerecorrd/src/flight/db/activeRecord/TableCreator.as:57]
    at Test/init()[/Users/seth/Flex/ActiveRecord/src/Test.mxml:16]

What version of the product are you using? On what operating system?
revision 12, OSX 10.5

Please provide any additional information below.
looking forward to testing again :)

Original issue reported on code.google.com by geekin...@gmail.com on 16 May 2008 at 9:01

GoogleCodeExporter commented 9 years ago
Yeah,

I can confirm this.  

Seems to be here (starting at line 54 in TableCreator.as):

            if (!schema)
            {
                var dbschema:SQLSchemaResult = DB.getSchema(obj.connection);

                var schema:SQLTableSchema;

                // first, find the table this object represents
                if (dbschema)
                {
                    for each (var tmpTable:SQLTableSchema in dbschema.tables)
                    {
                        if (tmpTable.name == tableName)
                        {
                            schema = tmpTable;
                            break;
                        }
                    }
                }
            }

            // if no table was found, create it, otherwise, update any missing fields
            if (!schema)
            {
 . . . 

I think it's a quick fix to the conditional statement or the placement of the
conditional statement.  

Original comment by mlegr...@gmail.com on 16 Sep 2008 at 12:09

GoogleCodeExporter commented 9 years ago
A quick fix could something like that:
if (!schema)
{
    try {
        var dbschema:SQLSchemaResult = DB.getSchema(obj.connection);
    } catch (e:SQLError) {
        //Do something
    }
    var schema:SQLTableSchema;

    // first, find the table this object represents
    if (dbschema)
    {
        for each (var tmpTable:SQLTableSchema in dbschema.tables)
        {
            if (tmpTable.name == tableName)
            {
                schema = tmpTable;
                break;
            }
        }
    }
}

Original comment by noirbiza...@gmail.com on 20 Oct 2008 at 7:06