Exposed Kotlin. Problem with cyrillic encoding











up vote
2
down vote

favorite
1












I tryed to fix a problem with encodings. So, I sent from 'Postman', from web browser request to server, where I search data in database by keys in request. Request can be like this:



http://localhost:8080/books.getBooksByGenre/Документальное/0/10


(in browser).
Server receive string, like



http://localhost:8080/books.getBooksByGenre/%D0%94%D0%BE%D0%BA%D1%83%D0%BC%D0%B5%D0%BD%D1%82%D0%B0%D0%BB%D1%8C%D0%BD%D0%BE%D0%B5/0/10


then, takes params from url:
genreName: 'Документальное'
start: 0
count: 10.
Then, this data sends to dao:



override fun findGenreByName(genreName: String): DatabaseGenre {
return transaction(db) { getGenreByName(genreName) }
}

private fun getGenreByName(genreName: String): DatabaseGenre {
return try {
val foundGenre = GenreEntity.find { Genres.genre eq genreName }.single()
DatabaseGenre(foundGenre.id.value, foundGenre.genre, foundGenre.link)
} catch (e: Exception) {
throw NothingFoundInDatabaseException("no one genre found by '$genreName'")
} catch (e: NoSuchElementException) {
val m = "Duplicates of genre with name '$genreName'"
throw DuplicatedDataInDatabaseException(m)
}
}


In log I see, that sql-query for finding genres is correct, but I receive an exception:



java.util.NoSuchElementException: Collection is empty.


The sql-query, as I said, is correct:



SELECT genres.id, genres.genre, genres.link FROM genres WHERE genres.genre = 'Документальное'


Structure of genres table:



genres
id: int(10)
genre: varchar(100)
link: varchar(100



I tryied, to select all genres, and this query executed almost correctly. So, I decided, to check this query with english word, and this query correctly executed:



SELECT genres.id, genres.genre, genres.link FROM genres WHERE genres.genre = 'simpleGenre'


I have not exceptions with this query.



So, what I've done wrong and how to fix problem with collations?



UPD:
As I said at github (issue), I've tryied this query it mysql cli and I receive correct answer.



Also, I've tryed to decode url params (with java URLDecoder class). It doesn't helps too.










share|improve this question
























  • Well, yeah. That's called URL encoding. If it doesn't automatically decode it, you'll need to do so manually.
    – Zoe
    yesterday










  • @Zoe, thanks for your answer. But, why I saw in logs sql-query with cyrillic letters (in "normal" form)? It was without encoded symbols, just normal cyrillic letters. p.s. I'll try your advice and write here results
    – Sergey Grishin
    yesterday












  • @Zoe, I've tryied your advice. It doesn't hepls. I updated my question description with my attempts to fix this problem and linkto github issue, where I wrote that from mysql cli all works fine
    – Sergey Grishin
    7 hours ago















up vote
2
down vote

favorite
1












I tryed to fix a problem with encodings. So, I sent from 'Postman', from web browser request to server, where I search data in database by keys in request. Request can be like this:



http://localhost:8080/books.getBooksByGenre/Документальное/0/10


(in browser).
Server receive string, like



http://localhost:8080/books.getBooksByGenre/%D0%94%D0%BE%D0%BA%D1%83%D0%BC%D0%B5%D0%BD%D1%82%D0%B0%D0%BB%D1%8C%D0%BD%D0%BE%D0%B5/0/10


then, takes params from url:
genreName: 'Документальное'
start: 0
count: 10.
Then, this data sends to dao:



override fun findGenreByName(genreName: String): DatabaseGenre {
return transaction(db) { getGenreByName(genreName) }
}

private fun getGenreByName(genreName: String): DatabaseGenre {
return try {
val foundGenre = GenreEntity.find { Genres.genre eq genreName }.single()
DatabaseGenre(foundGenre.id.value, foundGenre.genre, foundGenre.link)
} catch (e: Exception) {
throw NothingFoundInDatabaseException("no one genre found by '$genreName'")
} catch (e: NoSuchElementException) {
val m = "Duplicates of genre with name '$genreName'"
throw DuplicatedDataInDatabaseException(m)
}
}


In log I see, that sql-query for finding genres is correct, but I receive an exception:



java.util.NoSuchElementException: Collection is empty.


The sql-query, as I said, is correct:



SELECT genres.id, genres.genre, genres.link FROM genres WHERE genres.genre = 'Документальное'


Structure of genres table:



genres
id: int(10)
genre: varchar(100)
link: varchar(100



I tryied, to select all genres, and this query executed almost correctly. So, I decided, to check this query with english word, and this query correctly executed:



SELECT genres.id, genres.genre, genres.link FROM genres WHERE genres.genre = 'simpleGenre'


I have not exceptions with this query.



So, what I've done wrong and how to fix problem with collations?



UPD:
As I said at github (issue), I've tryied this query it mysql cli and I receive correct answer.



Also, I've tryed to decode url params (with java URLDecoder class). It doesn't helps too.










share|improve this question
























  • Well, yeah. That's called URL encoding. If it doesn't automatically decode it, you'll need to do so manually.
    – Zoe
    yesterday










  • @Zoe, thanks for your answer. But, why I saw in logs sql-query with cyrillic letters (in "normal" form)? It was without encoded symbols, just normal cyrillic letters. p.s. I'll try your advice and write here results
    – Sergey Grishin
    yesterday












  • @Zoe, I've tryied your advice. It doesn't hepls. I updated my question description with my attempts to fix this problem and linkto github issue, where I wrote that from mysql cli all works fine
    – Sergey Grishin
    7 hours ago













up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





I tryed to fix a problem with encodings. So, I sent from 'Postman', from web browser request to server, where I search data in database by keys in request. Request can be like this:



http://localhost:8080/books.getBooksByGenre/Документальное/0/10


(in browser).
Server receive string, like



http://localhost:8080/books.getBooksByGenre/%D0%94%D0%BE%D0%BA%D1%83%D0%BC%D0%B5%D0%BD%D1%82%D0%B0%D0%BB%D1%8C%D0%BD%D0%BE%D0%B5/0/10


then, takes params from url:
genreName: 'Документальное'
start: 0
count: 10.
Then, this data sends to dao:



override fun findGenreByName(genreName: String): DatabaseGenre {
return transaction(db) { getGenreByName(genreName) }
}

private fun getGenreByName(genreName: String): DatabaseGenre {
return try {
val foundGenre = GenreEntity.find { Genres.genre eq genreName }.single()
DatabaseGenre(foundGenre.id.value, foundGenre.genre, foundGenre.link)
} catch (e: Exception) {
throw NothingFoundInDatabaseException("no one genre found by '$genreName'")
} catch (e: NoSuchElementException) {
val m = "Duplicates of genre with name '$genreName'"
throw DuplicatedDataInDatabaseException(m)
}
}


In log I see, that sql-query for finding genres is correct, but I receive an exception:



java.util.NoSuchElementException: Collection is empty.


The sql-query, as I said, is correct:



SELECT genres.id, genres.genre, genres.link FROM genres WHERE genres.genre = 'Документальное'


Structure of genres table:



genres
id: int(10)
genre: varchar(100)
link: varchar(100



I tryied, to select all genres, and this query executed almost correctly. So, I decided, to check this query with english word, and this query correctly executed:



SELECT genres.id, genres.genre, genres.link FROM genres WHERE genres.genre = 'simpleGenre'


I have not exceptions with this query.



So, what I've done wrong and how to fix problem with collations?



UPD:
As I said at github (issue), I've tryied this query it mysql cli and I receive correct answer.



Also, I've tryed to decode url params (with java URLDecoder class). It doesn't helps too.










share|improve this question















I tryed to fix a problem with encodings. So, I sent from 'Postman', from web browser request to server, where I search data in database by keys in request. Request can be like this:



http://localhost:8080/books.getBooksByGenre/Документальное/0/10


(in browser).
Server receive string, like



http://localhost:8080/books.getBooksByGenre/%D0%94%D0%BE%D0%BA%D1%83%D0%BC%D0%B5%D0%BD%D1%82%D0%B0%D0%BB%D1%8C%D0%BD%D0%BE%D0%B5/0/10


then, takes params from url:
genreName: 'Документальное'
start: 0
count: 10.
Then, this data sends to dao:



override fun findGenreByName(genreName: String): DatabaseGenre {
return transaction(db) { getGenreByName(genreName) }
}

private fun getGenreByName(genreName: String): DatabaseGenre {
return try {
val foundGenre = GenreEntity.find { Genres.genre eq genreName }.single()
DatabaseGenre(foundGenre.id.value, foundGenre.genre, foundGenre.link)
} catch (e: Exception) {
throw NothingFoundInDatabaseException("no one genre found by '$genreName'")
} catch (e: NoSuchElementException) {
val m = "Duplicates of genre with name '$genreName'"
throw DuplicatedDataInDatabaseException(m)
}
}


In log I see, that sql-query for finding genres is correct, but I receive an exception:



java.util.NoSuchElementException: Collection is empty.


The sql-query, as I said, is correct:



SELECT genres.id, genres.genre, genres.link FROM genres WHERE genres.genre = 'Документальное'


Structure of genres table:



genres
id: int(10)
genre: varchar(100)
link: varchar(100



I tryied, to select all genres, and this query executed almost correctly. So, I decided, to check this query with english word, and this query correctly executed:



SELECT genres.id, genres.genre, genres.link FROM genres WHERE genres.genre = 'simpleGenre'


I have not exceptions with this query.



So, what I've done wrong and how to fix problem with collations?



UPD:
As I said at github (issue), I've tryied this query it mysql cli and I receive correct answer.



Also, I've tryed to decode url params (with java URLDecoder class). It doesn't helps too.







kotlin orm collate kotlin-exposed






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 7 hours ago

























asked yesterday









Sergey Grishin

1413




1413












  • Well, yeah. That's called URL encoding. If it doesn't automatically decode it, you'll need to do so manually.
    – Zoe
    yesterday










  • @Zoe, thanks for your answer. But, why I saw in logs sql-query with cyrillic letters (in "normal" form)? It was without encoded symbols, just normal cyrillic letters. p.s. I'll try your advice and write here results
    – Sergey Grishin
    yesterday












  • @Zoe, I've tryied your advice. It doesn't hepls. I updated my question description with my attempts to fix this problem and linkto github issue, where I wrote that from mysql cli all works fine
    – Sergey Grishin
    7 hours ago


















  • Well, yeah. That's called URL encoding. If it doesn't automatically decode it, you'll need to do so manually.
    – Zoe
    yesterday










  • @Zoe, thanks for your answer. But, why I saw in logs sql-query with cyrillic letters (in "normal" form)? It was without encoded symbols, just normal cyrillic letters. p.s. I'll try your advice and write here results
    – Sergey Grishin
    yesterday












  • @Zoe, I've tryied your advice. It doesn't hepls. I updated my question description with my attempts to fix this problem and linkto github issue, where I wrote that from mysql cli all works fine
    – Sergey Grishin
    7 hours ago
















Well, yeah. That's called URL encoding. If it doesn't automatically decode it, you'll need to do so manually.
– Zoe
yesterday




Well, yeah. That's called URL encoding. If it doesn't automatically decode it, you'll need to do so manually.
– Zoe
yesterday












@Zoe, thanks for your answer. But, why I saw in logs sql-query with cyrillic letters (in "normal" form)? It was without encoded symbols, just normal cyrillic letters. p.s. I'll try your advice and write here results
– Sergey Grishin
yesterday






@Zoe, thanks for your answer. But, why I saw in logs sql-query with cyrillic letters (in "normal" form)? It was without encoded symbols, just normal cyrillic letters. p.s. I'll try your advice and write here results
– Sergey Grishin
yesterday














@Zoe, I've tryied your advice. It doesn't hepls. I updated my question description with my attempts to fix this problem and linkto github issue, where I wrote that from mysql cli all works fine
– Sergey Grishin
7 hours ago




@Zoe, I've tryied your advice. It doesn't hepls. I updated my question description with my attempts to fix this problem and linkto github issue, where I wrote that from mysql cli all works fine
– Sergey Grishin
7 hours ago

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53360110%2fexposed-kotlin-problem-with-cyrillic-encoding%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53360110%2fexposed-kotlin-problem-with-cyrillic-encoding%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Volksrepublik China

How to test boost logger output in unit testing?

Write to the output between two pipeline