On Sep 2, 2014, at 11:05 AM, Ivan Smirnov <[email protected]> wrote:
> Yep, I'm aware of this workaround; however I'm trying to test the new pandas
> sqlalchemy bindings and they fail due to the problem above so it's out my
> control...
>
> Is there a way to fix this in SA? I'll take a look at the queries in debug
> mode.
Well yeah if we can get that column to come out in reflection, that helps. But
shorter, we should also get the index reflection to not fail if a column is not
found.
It looks like we are skipping so-called "system" columns for Oracle indexes
already, so that they aren't placed in the list:
oracle_sys_col = re.compile(r'SYS_NC\d+\$', re.IGNORECASE)
# ...
# filter out Oracle SYS_NC names. could also do an outer join
# to the all_tab_columns table and check for real col names there.
if not oracle_sys_col.match(rset.column_name):
index['column_names'].append(
self.normalize_name(rset.column_name))
I'm not sure what a SYS_NC name is either. do you have insight on what the
nature of the m_row$$ column means, and how analogous it is to this existing
"ignore" ?
it also is probably not a bad idea to put a final trap for this situation in
engine/reflection.py as well, so that we don't get a KeyError there.
these are all simple changes but they need unit tests written.
>
> On Tuesday, 2 September 2014 15:55:03 UTC+1, Michael Bayer wrote:
> it means that the query we do to reflect the columns in the table isn't
> coming up with this one.
>
>
> A possible workaround now is to just add this column explicitly:
>
> t = Table('mytable', m, Column('m_row$$', integer), autoload=True)
>
>
>
> On Sep 2, 2014, at 10:26 AM, Ivan Smirnov <[email protected]> wrote:
>
>> So, if I understand correctly, in this example m_row$$ is a hidden column
>> automatically generated when a materialized view is created with rowid. It's
>> still accessible though, i.e. you can still select from it explicitly.
>>
>> On Monday, 1 September 2014 18:46:39 UTC+1, Ivan Smirnov wrote:
>> py27/lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyc in
>> reflecttable(self, table, include_columns, exclude_columns)
>> 591 cols_by_orig_name[c] if c in cols_by_orig_name
>> 592 else table.c[c]
>> --> 593 for c in columns
>> 594 ],
>> 595 **dict(unique=unique))
>>
>> py27/lib/python2.7/site-packages/sqlalchemy/util/_collections.pyc in
>> __getitem__(self, key)
>> 155
>> 156 def __getitem__(self, key):
>> --> 157 return self._data[key]
>> 158
>> 159 def __delitem__(self, key):
>>
>> KeyError: u'm_row$$'
>> > py27/lib/python2.7/site-packages/sqlalchemy/util/_collections.py(157)__getitem__()
>> 156 def __getitem__(self, key):
>> --> 157 return self._data[key]
>> 158
>>
>>
>> If you have an index containing a column with a non-numeric character (like
>> 'm_row$$'), reflection would fail as in the example above, since table.c
>> would not contain it.
>>
>> Is there any way around it?
>>
>> P.S. It seems to be related to this thread from 4 years ago (MS SQL):
>> https://groups.google.com/forum/#!searchin/sqlalchemy/keyerror/sqlalchemy/BcANLqW1D04/sRPMYpDLO8oJ
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sqlalchemy" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/sqlalchemy.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.