springspring-data-r2dbc

Spring DatabaseClient fetch method returns columns values in different order with different column names


When using database client and fetch method which returns Map<String,Any>, the keys seem to be out of order. Am I doing something wrong here?

The code that fetches the map is

val result = databaseClient
                .sql(SELECT_ISSUER_METADATA)
                .bind(0, id)
                .fetch()
                .awaitOne()

The SELECT_ISSUER_METADATA is SELECT * FROM ISSUER_METADATA WHERE issuer = ? The table contains these columns and values when I ran the example: enter image description here

As you can see issuer has value soludcommunity.net while authorization_endpoint has the value soludcommunity.net/authorize.

But when I print the map I got from fetch I get this result:

{authorization_endpoint=https://solidcommunity.net, issuer=https://solidcommunity.net/authorize, jwk_uri=https://solidcommunity.net/jwks, registration_endpoint=https://solidcommunity.net/token, token_endpoint=https://solidcommunity.net/register}

Am I missing something simple here(I feel like this)?I don't know how to fix this.

I am using MySql R2dbc drivers.


Solution

  • This was due to a bug in the r2dbc-mysql driver, which has been fixed but not yet part of a stable release. So for now, the only option seems to be to use the build snapshot, which for maven would look something like:

        <properties>
            <r2dbc-mysql.version>0.8.3.BUILD-SNAPSHOT</r2dbc-mysql.version>
        </properties>
    
        <repositories>
            <repository>
                <id>sonatype-snapshots</id>
                <name>SonaType Snapshots</name>
                <url>https://oss.sonatype.org/content/repositories/snapshots</url>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
        </repositories>
    
        <dependencies>
            <dependency>
                <groupId>dev.miku</groupId>
                <artifactId>r2dbc-mysql</artifactId>
                <version>${r2dbc-mysql.version}</version>
            </dependency>
        <dependencies>