Output PostgreSQL enum types - schemacrawler

I have some custom enum types (e.g. CREATE TYPE speedType AS ENUM ('kph', 'mph', 'mps');) in a PostgreSQL DB. Can I output that with the Schemacrawler command line tool?

Enums types are supported as first-class schema metadata objects for PostgreSQL and MySQL, and displayed in the output since SchemaCrawler 16.4.1.
Sualeh Fatehi,
SchemaCrawler

Related

Import schema from XSD to OpenAPI/swagger YAML

I have a schema definition in a XSD file which is provided by ISO20022. This schema will need to be used in a swagger/openAPI definition (in yaml format). Since the XSD file has about 1000 lines, manual work is impracticable. This old thread mention some solution, but it is not straightforward.
Does anyone know any tool which provides an easy way to import the schema definitions from a XSD file into a swagger/openAPI yaml file?
You could try xsd2json from the npm module jgexml. It was written to do precisely this for a large API specified in XSD.
I could not escape from manual work in this task. What I've done was using "xsd2json" to convert the XSD schema to JSON. Then, I used the website www.json2yaml.com to get it as YAML. Afterwards, I created a swagger file myself, then merged the YAML file into it.
Thanks for your responses!

Terraform SDK - Custom Provider - how to accept JSON input in data source?

As far as I can tell, the Terraform SDK does not support an interface type. In my case I'm using a data resource to reach out to an API and pull JSON data. I would like to put that data in an attribute for later use in a resource but the problem is the JSON response has a large dictionary filled with different types. In GoLang this is no problem because you can set the map type to Interface{}. It would seem however that terraform only allows you to set the following types in a schema:
TypeInt
TypeString
TypeBool
TypeFloat
TypeInvalid
TypeList
TypeMap
Without support for interface how would you go about doing this correctly? The very ugly hack I have right now is converting everything to a string and then fixing the type once it is passed to the resource.
I asked on Hashicorp's forums and received a phenomenal answer here.
The synopsis is that casting to a string is currently the best solution. However there is a team working on making a new SDK design which would support newer capabilities to include arguments with dynamically chosen types.

How to view the SQL generated by an Opaleye query?

In the Opaleye Tutorial, line 88 lists the following example ghci command.
ghci> printSql personQuery
personQuery there is a predefined query, and it appears that printSql is a function which prints the SQL generated by it.
Where is this printSql function defined? I have searched through all the modules of the opaleye package and do not see it defined there.
How can I see the SQL generated by an opaleye query?

Get a list of all the arguments a constructor takes

Is it possible to get a list of all the arguments a constructor takes?
With the names and types of the parameters?
I want to automatically check the values of a JSON are good to use for building their equivalent as a class instance.
Preferably without macros... I have build a few, but I still find them quiet confusing.
Must work with neko and JS, if that maters.
Thanks.
I think you want to look at Runtime Type Information (rtti)
From the Haxe Manual: The Haxe compiler generates runtime type information (RTTI) for classes that are annotated or extend classes that are annotated with the #:rtti metadata. This information is stored as a XML string in a static field __rtti and can be processed through haxe.rtti.XmlParser. The resulting structure is described in RTTI structure.
Alternative; If you want to go with macros, this might be a good start
http://code.haxe.org/category/macros/add-parameters-as-fields.html

Using libphonenumber library in postgresql function

I need to parse phone numbers in a postgresql function. I am using waterline ORM and was basically doing this computation in javascript. Now I want to move the entire logic to postgresql stored function. But the bottleneck is the availability of libphonenumber library. It's available in Node.js but not sure how to use it in postgresql.
Any idea ?
There are C bindings available for libphonenumber already
CREATE EXTENSION pg_libphonenumber;
SELECT parse_phone_number('03 7010 1234', 'AU') = parse_phone_number('(03) 7010 1234', 'AU');
CREATE TABLE foo
AS
SELECT DISTINCT parse_phone_number(ph, 'AU')
FROM ( VALUES
('0370101234'),
('03 7010 1234'),
('(03) 7010 1234')
) AS t(ph);
Find my answer here for more information
Since it's available in C++ and JavaScript, you could:
Install and load PL/V8 and use it as a JavaScript library in a PL/V8 stored procedure; or
Write a C extension for PostgreSQL that exposes the functions as SQL-callable functions by wrapping the C++ functions in the C++ version of the library.
Needless to say, the former is probably easier, unless you're comfortable with C programming.

Resources