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

feat: start work on uuid support #411

Draft
wants to merge 41 commits into
base: master
Choose a base branch
from

Conversation

iamwacko
Copy link
Collaborator

@iamwacko iamwacko commented Jan 20, 2023

UUID was implemented as a string, which meant it would not work with the UUID type in databases. #270

@iamwacko iamwacko marked this pull request as draft January 20, 2023 15:43
@iamwacko
Copy link
Collaborator Author

If anyone wants this merged they have to figure out how to make pretty printing the OwnedSerializable in the test_compile_and_generate test in the core crate not give an error along the lines of key must be a string.

@iamwacko iamwacko added the help wanted Extra attention is needed label Jan 24, 2023
@ratskates
Copy link

Any chance of getting this merged in ? It's a read blocker for me.

@JRileyH
Copy link

JRileyH commented Apr 17, 2023

What's the realistic timeline of getting this merged? I cannot use synth until UUIDs are supported in postgres.

Also thanks for taking his on @iamwacko :) Looks like more than a few people will be really happy to see this fixed.

@iamwacko
Copy link
Collaborator Author

I don't really have a schedule. It should be working, and rust-gdb even shows UUID's in memory. The only blocker is the key must be a string error, which I have spent hours trying to fix. If anyone could figure out how to deal with it I could put out a new release that day.

@njohnson-ml
Copy link

@iamwacko do you get any more info on the failure when you set RUST_BACKTRACE=1?

@murugesanp92
Copy link

@iamwacko any progress on this?

@F3ss
Copy link

F3ss commented Dec 20, 2024

Perhaps this will help someone as a temporary solution: generate data in a json file synth generate ./my-table --size 50000 > .tmp/my-table.json, convert it to CSV in a convenient way for you and save it in the database.

My python script for convert to CSV: ```
import json
import csv
from datetime import datetime

def json_to_csv(json_file, csv_file):
try:
with open(json_file, 'r', encoding='utf-8') as f:
data = json.load(f)

    if 'attribute' not in data:
        raise KeyError("Key 'attribute' not found in JSON file")

    with open(csv_file, 'w', newline='', encoding='utf-8') as csvfile:
        fieldnames = ['attribute_id', 'created_at', 'id', 'name', 'value']
        writer = csv.DictWriter(csvfile, fieldnames=fieldnames)

        writer.writeheader()

        for item in data['attribute']:
            attribute_id = item.get('attribute_id', '')
            created_at = item.get('created_at', '')
            try:
                created_at = datetime.strptime(created_at, '%Y-%m-%d %H:%M:%S.%f')
            except ValueError:
                pass

            row = {
                'attribute_id': attribute_id,
                'created_at': created_at,
                'id': item.get('id', ''),
                'name': item.get('name', ''),
                'value': json.dumps(item.get('value', {}))
            }

            writer.writerow(row)

    print(f"Data successfully written to {csv_file}")

except Exception as e:
    print(f"An error occurred: {e}")

json_file_path = '.tmp/my-table.json'
csv_file_path = '.tmp/my-table.csv'

json_to_csv(json_file_path, csv_file_path)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants