sql-metadata icon indicating copy to clipboard operation
sql-metadata copied to clipboard

Table name is altered when it contains a number

Open domecrane opened this issue 4 years ago • 1 comments

Hi, I would like to thank you for this tool, it's awesome!

Although, I found a bug. I left a comment on another issue to understand what the issue is I am facing with.

I found a method/function called .generalize which is cool, but when the table name contains a number like 1, 2..., it is replaced with an 'N' character.

Here is an example:

query_alt = 'select count(1) from dummy_table_1'
Parser(Parser(query_alt).generalize).tables

The result is: ['dummy_table_N']

Could you please take a look at it?

Thank you!

domecrane avatar Dec 22 '21 13:12 domecrane

I think that's the point of .generalize:

generalize : str (property)
Removes most variables from an SQL query and replaces them with X or N for numbers.

Based on Mediawiki's DatabaseBase::generalizeSQL 

howardrcc avatar Jul 07 '22 10:07 howardrcc