Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backwards compatibility issue for timepoint in stop_times #41

Open
peetjvv opened this issue Jul 11, 2017 · 2 comments
Open

backwards compatibility issue for timepoint in stop_times #41

peetjvv opened this issue Jul 11, 2017 · 2 comments

Comments

@peetjvv
Copy link
Contributor

peetjvv commented Jul 11, 2017

I haven't tested it to see what would happen, but there is a backward compatibility issue when adding more columns to existing tables in the way that you did it. I would suggest adding this line to the end of SQLiteGTFSFeedDb.RebuildDb():

if (!ColumnExists("stop_time", "timepoint")) this.ExecuteNonQuery("ALTER TABLE [stop_time] ADD [timepoint] TEXT;");

this uses the new method in RebuildDb():

    /// <summary>
    /// Checks if the given table contains a column with the given name.
    /// </summary>
    /// <param name="tableName">The table in this database to check.</param>
    /// <param name="columnName">The column in the given table to look for.</param>
    /// <returns>True if the given table contains a column with the given name.</returns>
    private bool ColumnExists(string tableName, string columnName)
    {
        var cmd = new SQLiteCommand("PRAGMA table_info(" + tableName + ")", _connection);
        var dr = cmd.ExecuteReader();
        while (dr.Read())
        {
            var value = dr.GetValue(1);//column 1 from the result contains the column names
            if (columnName.Equals(value))
            {
                dr.Close();
                return true;
            }
        }

        dr.Close();
        return false;
    }

Further, I noticed that there are 2 CREATE TABLE statements for the stop_time table in RebuildDb. Not entirely sure what the effect of this is going to be, but I'm pretty sure it would just go ahead and create the table with the old structure (first CREATE TABLE command) and ignore the new structure.

@peetjvv
Copy link
Contributor Author

peetjvv commented Jul 11, 2017

I also noticed that you made shape_dist_traveled in stop_time a REAL value instead of TEXT

@peetjvv
Copy link
Contributor Author

peetjvv commented Nov 9, 2020

@xivk I see this old issue of mine is still open. I also noticed you removed the GTFS SQLite db code from this repo along with some other code not related to reading/parsing, handling and writing GTFS feeds in this commit.
Out of curiosity, did you move that code elsewhere? Or did you decide to no longer support databases?

You can feel free to close this issue btw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant