mtxr / vscode-sqltools

Database management for VSCode
https://vscode-sqltools.mteixeira.dev?utm_source=github&utm_medium=homepage-link
MIT License
1.48k stars 296 forks source link

Remove duplicates from table columns #686

Open emil14 opened 4 years ago

emil14 commented 4 years ago

Hello! And thank you for great extension!

It would be great if we could see columns without duplicate rows. What I mean:

Screenshot from 2020-08-24 13-48-11

To me it looks like a made mistake in SQL or something. Would be great to see a single row for a single column

Thanks! :)

emil14 commented 4 years ago

Another problem related to this is when I click "Generate insert query" it generates query with duplicates

INSERT INTO some_table (
    service_id,
    service_id,
  )
VALUES (
    'service_id:uuid',
    'service_id:uuid',
  );
mtxr commented 4 years ago

@emil14 which driver are you using?

emil14 commented 4 years ago

@mtxr I'm using "SQLTools PostgreSQL/Redshift Driver"

mtxr commented 4 years ago

I'm not able to reproduce this.

Are you using extension and latest versions?

image

mtxr commented 4 years ago

Tested on PostgreSQL 12.2 (Debian 12.2-2.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit image

emil14 commented 4 years ago

@mtxr I'm using the same versions of "SQLTools" and "PostgreSQL/Redshift Driver" on Ubuntu 18.04.5 LTS

emil14 commented 4 years ago

Screenshot from 2020-08-27 19-36-09

Here's what I have :)

emil14 commented 1 year ago

Hey there! Any progress?

create table if not exists users (
    id serial primary key,
    tg_chat_id integer unique check (tg_chat_id > 0)
);

create table if not exists assets (
    id serial primary key,
    name varchar(255) not null unique
);

create table if not exists accounts (
    id serial primary key,
    user_id integer references users(id),
    name varchar(255) not null,
    asset_id integer references assets(id),
    unique(user_id, name)
);

create table if not exists users_accounts (
    id serial primary key,
    user_id integer references users(id),
    account_id integer references accounts(id),
    unique(user_id, account_id)
);

Screenshot from 2023-06-30 10-15-18

emil14 commented 1 year ago

I could fix this by myself but have no idea how this work. I know fullstack web dev thought. We can have zoom call and fix it together :)

emil14 commented 1 year ago

:(

starball5 commented 8 months ago

Potentially related on Stack Overflow: VSCode extension "SQL Tools" showing duplicate attributes in mysql database

fzhem commented 4 months ago

@emil14 The error is most likely in the query that gets a list of columns for the side panel: https://github.com/mtxr/vscode-sqltools/blob/dev/packages/driver.pg/src/ls/queries.ts. Check fetchColumns query. Can you run that query on databases where you see duplicate columns?

fzhem commented 4 months ago

I reckon it's because the join condition isn't restrictive enough. I don't know enough about postgres to comment on what exactly but I'd start the investigation from there. I'll try to reproduce it this weekend hopefully