kellerkindt / asn1rs

Generates Rust Code and optionally compatible Protobuf schema files from ASN.1 definitions.
http://asn1.rs
Apache License 2.0
55 stars 20 forks source link

SQL generator might needs to re-order declarations #39

Closed kellerkindt closed 3 years ago

kellerkindt commented 3 years ago

itu-t(0) identified-organization(4) etsi(0) itsDomain(5) wg1(1) en(302637) cam(2) version(1) first declares ItsPduHeader - which uses StationID - and then declares StationID. The resulting SQL code looks something like this:

CREATE TABLE ItsPduHeader (
    id SERIAL PRIMARY KEY,
    protocol_version SMALLINT NOT NULL,
    message_id SMALLINT NOT NULL,
    station_id INTEGER REFERENCES StationID(id) ON DELETE CASCADE ON UPDATE CASCADE NOT NULL
);

CREATE INDEX ON ItsPduHeader(station_id);

CREATE TABLE StationID (
    id SERIAL PRIMARY KEY
);

This does not work, because while creating the ItsPduHeader the table for StationID does not yet exist and can therefore not be referenced.