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

sql-insert format emits NULL as 'None' #1408

Closed
3 tasks done
Smylers opened this issue Jun 22, 2023 · 3 comments
Closed
3 tasks done

sql-insert format emits NULL as 'None' #1408

Smylers opened this issue Jun 22, 2023 · 3 comments

Comments

@Smylers
Copy link

Smylers commented Jun 22, 2023

Description

When using the new sql-insert format that @astroshot added in #1366, any NULL value in the data is displayed as the string 'None'.

This obviously corrupts the data when the INSERT statement is run — either inserting a string that shouldn't be there, or where 'None' isn't a valid value (for instance in a numeric field, or where a non-NULL value needs to match a foreign key), just refusing to insert anything.

Demo:

clegg> SELECT NULL::INTEGER AS number, 'None'::TEXT AS word
+--------+------+
| number | word |
|--------+------|
| ⟨NULL⟩ | None |
+--------+------+
SELECT 1
Time: 0.013s
clegg> \T sql-insert
Changed table format to sql-insert
Time: 0.000s
clegg> SELECT NULL::INTEGER AS number, 'None'::TEXT AS word
INSERT INTO ""DUAL"" ("number", "word") VALUES
  ('None', 'None')
;
SELECT 1
Time: 0.002s

Your environment

  • Please provide your OS and version information.

    Ubuntu 22.04 LTS

  • Please provide your CLI version.

    Version: 3.5.0

  • What is the output of pip freeze command.

apt-clone==0.2.1
apturl==0.5.2
ayatana-settings==21.1.28
bcrypt==3.2.0
blinker==1.4
Brlapi==0.8.3
brz-etckeeper==0.0.0
cajarename==21.11.24
chardet==4.0.0
cli-helpers==2.3.0
click==8.0.3
colorama==0.4.4
command-not-found==0.3
configobj==5.0.6
cryptography==3.4.8
cupshelpers==1.0
dbus-python==1.2.18
defer==1.0.6
deja-dup-caja==0.0.9
distro==1.7.0
distro-info===1.1build1
duplicity==0.8.21
Entroware Support Hub==22.4.10
evdev==1.4.0
fasteners==0.14.1
feedparser==6.0.8
folder-color-caja==0.0.86
folder-color-common==0.0.86
future==0.18.2
gpg===1.16.0-unknown
httplib2==0.20.2
importlib-metadata==4.6.4
jeepney==0.7.1
keyring==23.5.0
language-selector==0.1
launchpadlib==1.10.16
lazr.restfulclient==0.14.4
lazr.uri==1.0.6
lockfile==0.12.2
louis==3.20.0
Magnus==1.0.3
Mako==1.1.3
MarkupSafe==2.0.1
mate-hud==22.4.4
mate-menu==22.4.1
mate-tweak==22.4.8
monotonic==1.6
more-itertools==8.10.0
musicbrainzngs==0.7.1
mutagen==1.45.1
netifaces==0.11.0
oauthlib==3.2.0
olefile==0.46
onboard==1.4.1
PAM==0.4.2
paramiko==2.9.3
pendulum==2.1.2
pexpect==4.8.0
pgcli==3.5.0
pgspecial==2.1.0
Pillow==9.0.1
prompt-toolkit==3.0.38
psutil==5.9.0
psycopg==3.1.9
ptyprocess==0.7.0
pulsemixer==1.5.1
pycairo==1.20.1
pycryptodomex==3.11.0
pycups==2.0.1
Pygments==2.15.1
PyGObject==3.42.1
PyICU==2.8.1
pyinotify==0.9.6
PyJWT==2.3.0
pymacaroons==0.13.0
PyNaCl==1.5.0
pyparsing==2.4.7
python-apt==2.4.0+ubuntu1
python-dateutil==2.8.1
python-debian===0.1.43ubuntu1
python-xapp==2.2.1
python-xlib==0.29
pytzdata==2020.1
pyxattr==0.7.2
pyxdg==0.27
PyYAML==5.4.1
quodlibet==4.4.0
reportlab==3.6.8
SecretStorage==3.3.1
setproctitle==1.2.2
sgmllib3k==1.0.0
six==1.16.0
sqlparse==0.4.4
sshtunnel==0.4.0
systemd-python==234
tabulate==0.9.0
typing_extensions==4.6.3
ubuntu-advantage-tools==8001
ubuntu-drivers-common==0.0.0
ufw==0.36.1
unattended-upgrades==0.1
urllib3==1.26.5
usb-creator==0.3.7
wadllib==1.3.6
wcwidth==0.2.6
xdg==5
xkit==0.0.0
youtube-dl==2021.12.17
zipp==1.0.0
@Smylers Smylers changed the title is:issue is:open sql-insert format emits NULL as 'None' sql-insert format emits NULL as 'None' Jun 22, 2023
@astroshot
Copy link
Contributor

Let me see... I'll fix it later.

astroshot added a commit to astroshot/pgcli that referenced this issue Jun 23, 2023
Body:
1. Fix issue dbcli#1408 sql-insert format emits NULL as 'None';
2. Fix DUAL displays as ""DUAL"";

==== End ====
astroshot added a commit to astroshot/pgcli that referenced this issue Jun 23, 2023
Body:
1. Fix issue dbcli#1408 sql-insert format emits NULL as 'None';
2. Fix DUAL displays as ""DUAL"";

==== End ====
@astroshot
Copy link
Contributor

@Smylers I have it fixed in pull request #1409.

j-bennet pushed a commit that referenced this issue Jun 23, 2023
* Sub: Fix issue #1408

Body:
1. Fix issue #1408 sql-insert format emits NULL as 'None';
2. Fix DUAL displays as ""DUAL"";

==== End ====

* Sub: Update changelog.rst

Body:

==== End ====

* Sub: Optimize if logic

Body:

==== End ====
@j-bennet
Copy link
Contributor

Fixed via #1409.

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

3 participants