yaml-cpp: Is it possible to use Merge Key Language-Independent Type? - yaml-cpp

Yaml spec 1.1 has Merge Key Language-Independent Type
Is it possible to parse this merge key from yaml-cpp?

Related

How is the internal table sorted by default?

So i was wondering if when i declare
lt_table TYPE STANDARD TABLE OF mara.
Is it the same as
lt_table TYPE STANDARD TABLE OF mara WITH DEFAULT KEY.
Or are the standard table keys selected differently when not declaring DEFAULT KEY?
That's the same, as explained in the ABAP documentation:
If no explicit primary key is defined for a standard table, it automatically has a standard key.
A standard key is when you indicate DEFAULT KEY (first bullet point below) or nothing (second one):
The standard key can be declared as follows:
Explicitly, using the additions UNIQUE|NON-UNIQUE KEY of the statements TYPES, DATA and so on, where the addition DEFAULT KEY is specified instead of the list of components.
Implicitly, if no explicit primary key specification is made in the declaration of a standard table with the statement DATA.
Implicitly, if a standard table type with a generic primary table key is specified behind TYPE in the statement DATA.
EDIT May 31st, 2022: there can be some confusion about the meaning of the "keys of a standard table". That could make people think that the table is sorted and the access is then faster.
That's wrong.
It will be faster only if you sort explicitly your internal table SORT itab BY comp1 comp2 (once as it's time consuming), and use READ TABLE itab WITH KEY comp1 = ... comp2 = ... BINARY SEARCH.
Declaring the primary key (default key or explicit components) of a standard table is a way to not mention the components after SORT, READ TABLE, etc., but the ABAP documentation recommends to explicitly declare them after SORT, READ TABLE, etc.
Consequently, I don't see any interest in declaring the primary key of a standard table.
NB: COLLECT works only based on the primary key of the standard table, so here there's no choice except if you replace COLLECT with code like this for instance:
ASSIGN itab[ c1 = line-c1 c2 = line-c2 ] TO FIELD-SYMBOL(<exist_line>).
IF sy-subrc = 0.
<exist_line>-counter = <exist_line>-counter + line-counter.
ELSE.
INSERT line INTO TABLE itab.
ENDIF.
If you want to use a sorted table for faster access, prefer declaring the table with TYPE SORTED TABLE or TYPE HASHED TABLE (or any alternate syntax to have Secondary Keys), it will really sort the table and accesses are faster, the compiler will send better warning or error messages with SORT (error because already sorted), READ TABLE, etc., than for a standard table (only some warnings if you use ATC).
For more information, see ABAP documentation - itab - Selection of the Table Category

Using jOOQ DAO to delete a record with composite key

I have a table with a composite key, and one additional field. Using standard generated jOOQ DAO, how can a I delete a record?
The API wants a Record2, but I'm not sure how to create one? This is what I currently do:
val pojo = Pojo(key1Uuid, key2Uuid, LocalDateTime.MIN)
dao.delete(pojo)
I don't like that I need to provide some bogus data to the last field.
Is there a more elegant way of doing this?
There is currently no other way than to either:
Use the entire POJO type (as you did)
Supply the Record2 type as follows
ctx.newRecord(TABLE.COL1, TABLE.COL2).values(key1Uuid, key2Uuid)
See: DSLContext.newRecord(Field<T1>, Field<T2>)

Controlling schema created by Database.Persist

I'm learning Haskell, and my first real app is a web application using Yesod + Database.Persist with the SQLite backend, but I can't find a way to specify some things with the persistLowerCase quasi quoter:
How to declare a specified column should be indexed (without the uniqueness constraint)
How to specify foreign keys (I can only do foreign_table_id ForeignTableId, which translates to "foreign_table_id" INTEGER NOT NULL REFERENCES "foreign_table")
How to specify column sizes (VARCHAR(50), for instance)
How to use CHAR and BLOB as a column type
The last two are not useful for SQLite proper, but I might change database backends in the future.
If I remember correctly (from a presentation about Yesod at InfoQ), adding an index must be done manually, there's no support in Yesod for doing it automatically.
Column sizes can be specified by typing maxlen=<size> in the field definition. BLOBs can be stored as a ByteStrings. An example for both fields looks like this:
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
Something
b ByteString
t Text maxlen=30
|]
The BLOB data type will work with Sqlite3, since I've used it in the past, but I don't know for sure about the maxlen attribute, I just read about it. You can find more details in the Yesod book, chapter about Persistent.
As for the foreign keys, my experience tells me that those are synonyms. Just don't forget to enable foreign keys, since they're disabled by default.

Fluent Nhibernate mapping Legacy DB with composite key

I am using Fluent NHibernate (which I am fairly new to) in an application I am developing using a legacy Oracle DB. The DB has composite keys which are comprised of foreign keys and database generated columns. The generated columns are supplied by calling a DB function with the table name, and one of the other foreign key parts. The generated composite key parts are not unique, and I cannot change this. The generated key parts are often used as foreign keys on other tables too.
If I create entity mapping which specifies the composite key as it is in the database, then we cannot use any identity generation strategies, which breaks unit of work
If I create entity mapping which specifies only the generated column as the primary key, then I can use trigger-identity to generate the ids, and I get unit of work, but I then have a problem when I want to update, or access a child collection: The other parts of the key are not included in the WHERE statement.
Can anyone give me any advice on how to proceed?
If I stick with mapping composite keys, can I extend nhibernate to output the SQL to use trigger-identity? If so, can you suggest a starting point?
If I map a single column key, can I include other properties in a WHERE clause for HasMany mapping and Updates?
Unfortunately, as you have already found out, there is no support at all for this setup.
My suggestion is to do INSERTS manually (using custom SQL, for example). And yes, this breaks the UoW, but that is true of identity too.

Mapping a primary key of type binary(16)

I have a legacy schema that contains tables with composite keys where some of the keys are of type binary(16) -- its a MD5 hash of the other columns. I am having trouble finding the right way to map this structure. The first thing I tried was to simply use byte[] as my domain type, which NHibernate quickly dismissed since byte[] does not implement Equals (duh!). The next thing I tried was to create a custom user type (i.e., implements IUserType) to wrap the byte[] and provide the requisite Equals implementation but this did not work since it appears that NHibernate (v2.1.2) does not support user types in composite keys. The last thing I tried was to use Guid as my domain type hoping that NHibernate would automagically CAST or CONVERT between my domain type (uniqueidentifier) and my column type (binary(16)); it did not. I am currently looking for a way to force NHibernate to wrap all usages of a column c in a CONVERT(uniqueidentifier, c). Is this possible or is there another way to make this work?
I don't know nhibernate, but I think this is really an SQL question.
Any reason you can't create a view on the table, and add a new indexed field (I'm assuming ms-sql here) or similar that casts the binary(16) or a uniqueidentifier or nvarchar ?