Skip to content

[formatting] align_decimal preprocessor not wanted for sql-insert output formatter? #635

@tmijieux

Description

@tmijieux

'preprocessors': (preprocessors.align_decimals, ),

When using sql-insert output format, the align_decimal preprocessor is being used,
As a result, the generated sql request will contain string, where it should contain a unquoted float literal.


test> desc exampletable
+-------+---------+------+-----+---------+----------------+
| Field | Type    | Null | Key | Default | Extra          |
+-------+---------+------+-----+---------+----------------+
| id    | int(11) | NO   | PRI | <null>  | auto_increment |
| value | float   | NO   |     | 0       |                |
+-------+---------+------+-----+---------+----------------+
2 rows in set
Time: 0.012s
test> SELECT * FROM exampletable
+----+-------+
| id | value |
+----+-------+
| 1  |  3.4  |
| 2  | 54.0  |
+----+-------+
2 rows in set
Time: 0.007s
test> \T sql-insert
Changed table format to sql-insert
Time: 0.000s
test> SELECT * FROM exampletable
INSERT INTO `exampletable` (`id`, `value`) VALUES
(1, ' 3.4')
, (2, '54.0')
;

In the code above, it can be seen that the align processor is used in the first case with the ascii formatter and that is fine, but in the second case with sql-insert formatter, the numbers are quoted and there is a leading whitespace before 3.4 because of the align_decimal preprocessor.

I am not sure if this is really a bug, or a feature, but at least in my case I would like to avoid this behaviour, for sql-insert output format.
Would it be possible to drop the align_decimal preprocessor for the sql output formatters?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions