ManageIQ / manageiq-smartstate

Apache License 2.0
4 stars 36 forks source link

Allow quotes around 'TableName' in sqlite schema #204

Closed agrare closed 2 weeks ago

agrare commented 2 weeks ago

The regex from the current schema parser doesn't allow for e.g. CREATE TABLE 'Packages' like we see with the rpmdb.sqlite file.

This would lead to an exception when listing the tables

     Failure/Error: tname = m[1].to_s.chomp

     NoMethodError:
       undefined method `[]' for nil
     # ./lib/db/MiqSqlite/MiqSqlite3Table.rb:68:in `decodeSchema'
     # ./lib/db/MiqSqlite/MiqSqlite3Table.rb:59:in `initialize'
     # ./lib/db/MiqSqlite/MiqSqlite3Table.rb:38:in `new'
     # ./lib/db/MiqSqlite/MiqSqlite3Table.rb:38:in `block (2 levels) in each'
     # ./lib/db/MiqSqlite/MiqSqlite3Page.rb:91:in `block in each_cell'
     # ./lib/db/MiqSqlite/MiqSqlite3Page.rb:91:in `each'
     # ./lib/db/MiqSqlite/MiqSqlite3Page.rb:91:in `each_cell'
     # ./lib/db/MiqSqlite/MiqSqlite3Table.rb:37:in `block in each'
     # ./lib/db/MiqSqlite/MiqSqlite3Page.rb:84:in `block in each_child'
     # ./lib/db/MiqSqlite/MiqSqlite3Page.rb:91:in `block in each_cell'
     # ./lib/db/MiqSqlite/MiqSqlite3Page.rb:91:in `each'
     # ./lib/db/MiqSqlite/MiqSqlite3Page.rb:91:in `each_cell'
     # ./lib/db/MiqSqlite/MiqSqlite3Page.rb:83:in `each_child'
     # ./lib/db/MiqSqlite/MiqSqlite3Table.rb:35:in `each'
     # ./lib/db/MiqSqlite/MiqSqlite3Table.rb:11:in `table_names'
     # ./lib/db/MiqSqlite/MiqSqlite3.rb:307:in `table_names'
     # ./spec/db/MiqSqlite/rpmdb_spec.rb:35:in `block (2 levels) in <top (required)>'

Fixes https://github.com/ManageIQ/manageiq-smartstate/issues/205