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

Procedures in PSQL are not replaced #3587

Open
DawnKosmos opened this issue Sep 6, 2024 · 0 comments
Open

Procedures in PSQL are not replaced #3587

DawnKosmos opened this issue Sep 6, 2024 · 0 comments
Labels

Comments

@DawnKosmos
Copy link

Version

1.27.0

What happened?

While replacing a procedure in PSQL migration I noticed that SQLC generates the Procedures Struct using the old procedure parameter types somehow mixed with the new one, although the procedure is dropped in the code and re-created with a different schema.

Relevant log output

No response

Database schema

CREATE OR REPLACE PROCEDURE create_contract(
  p_location_id UUID,
  p_supplier_id UUID,
  p_contract_id UUID,
  p_account_id VARCHAR(31),
  p_country country_codes,
  p_has_medical_access BOOLEAN,
  p_organization_id UUID,
  p_group_id UUID,
  p_valid_from TIMESTAMP,
  p_valid_to TIMESTAMP,
  p_language VARCHAR(2),
  p_type VARCHAR(31),
  p_comment text
)
  LANGUAGE plpgsql
AS
$$
BEGIN
  INSERT INTO public.contracts (location_id,
                                supplier_id,
                                contract_id,
                                account_id,
                                country,
                                has_medical_access,
                                created_at,
                                updated_at,
                                deleted_at,
                                organization_id,
                                group_id,
                                valid_from,
                                valid_to,
                                language,
                                type,
                                comment)
  VALUES (p_location_id,
          p_supplier_id,
          p_contract_id,
          p_account_id,
          p_country,
          p_has_medical_access,
          now(),
          now(),
          null,
          p_organization_id,
          p_group_id,
          p_valid_from,
          p_valid_to,
          p_language,
          p_type,
          p_comment);
END;
$$;

SQL queries

-- name: CreateContract :exec
CALL create_contract(
  sqlc.arg(p_location_id),
  sqlc.arg(p_supplier_id),
  sqlc.arg(p_contract_id),
  sqlc.arg(p_account_id),
  sqlc.arg(p_country),
  sqlc.arg(p_has_medical_access),
  sqlc.arg(p_organization_id),
  sqlc.narg(group_id),
  sqlc.arg(p_valid_from),
  sqlc.arg(p_valid_to),
  sqlc.arg(p_language),
  sqlc.arg(p_type),
    sqlc.arg(p_comment)
);

Configuration

type CreateContractParams struct {
	PLocationID       uuid.UUID         `db:"p_location_id" json:"p_location_id"`
	PSupplierID       uuid.UUID         `db:"p_supplier_id" json:"p_supplier_id"`
	PContractID       uuid.UUID         `db:"p_contract_id" json:"p_contract_id"`
	PAccountID        string            `db:"p_account_id" json:"p_account_id"`
	PCountry          CountryCodes      `db:"p_country" json:"p_country"`
	PHasMedicalAccess bool              `db:"p_has_medical_access" json:"p_has_medical_access"`
	POrganizationID   bool             // TYPE SHOULD BE UUID
	GroupID           uuid.NullableUUID `db:"group_id" json:"group_id"`
	PValidFrom        bool              //TYPE SHOUDL BE pgtype.Timestamp
	PValidTo          pgtype.Timestamp  `db:"p_valid_to" json:"p_valid_to"`
	PLanguage         pgtype.Timestamp  // SHOULD BE TEXT
	PType             string            `db:"p_type" json:"p_type"`
	PComment          string            `db:"p_comment" json:"p_comment"`
}

Playground URL

No response

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@DawnKosmos DawnKosmos added the bug Something isn't working label Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant