> In order not to block the interpreter, Sequel uses #async_exec and not #exec on the PG::Connection. Perhaps that's the cause of the problem? Do you get the same results as Sequel if you use #async_exec on the PG::Connection (with #block afterward)?
After change from db = PG.connect(URI(DB_URL)) db.exec("UPDATE investing_latest_news SET title = title;") To db.async_exec("UPDATE investing_latest_news SET title = title;") It still work. ---------------------------- I don't sure about what is you means of "with #block afterward" , maybe you want DB.synchronize do |conn| conn.async_exec("UPDATE investing_latest_news SET title = title;") end or DB.synchronize do |conn| conn.exec("UPDATE investing_latest_news SET title = title;") end Above two cases both NOT work. 在2021年11月22日星期一 UTC+8 下午11:55:00<Jeremy Evans> 写道: > On Sun, Nov 21, 2021 at 7:15 PM Billy Zheng <vil...@gmail.com> wrote: > >> >> Sad, in my ability, there is no way can reproduce this if not use >> zhparser. >> > > Unfortunately, I won't be able to help debug in that case. > > >> >> i still consider some incompatible things exists when do UPDATE use >> DB.run on sequel, e.g. pg function, triggers or others, >> because use pg gem always work. >> > > You can do: > > DB.synchronize do |conn| > # conn here is the PG::Connection instance > end > > I'm not sure why behavior would be different, but that is a simple way to > use the connection directly if you need to. > > >> >> the last try, maybe there exists some clue on "DB.run("SELECT >> sync_zhprs_custom_word();")" >> >> could you please check this function? >> >> ``` >> CREATE or REPLACE FUNCTION sync_zhprs_custom_word() RETURNS void >> LANGUAGE plpgsql AS >> $$ >> declare >> data_dir text; >> dict_path text; >> time_tag_path text; >> query text; >> begin >> select setting from pg_settings where name='data_directory' into >> data_dir; >> >> select data_dir || '/base/' || '/zhprs_dict_' || current_database() || ' >> .txt' into dict_path; >> select data_dir || '/base/' || '/zhprs_dict_' || current_database() || ' >> .tag' into time_tag_path; >> >> query = 'copy (select word, tf, idf, attr from >> zhparser.zhprs_custom_word) to ' || chr(39) || dict_path || chr(39) || ' >> encoding ' || chr(39) || 'utf8' || chr(39) ; >> execute query; >> query = 'copy (select now()) to ' || chr(39) || time_tag_path || chr(39) >> ; >> execute query; >> end; >> $$; >> >> ``` >> > > This executes a query twice, maybe that has something to do with it? > > >> i think debug this issue is easy if we can know the exactly SQL send to >> pg when do `DB.run("????")`, if i can suppose it must not same as >> `pg_conn.exec("????")`, right? so, could you please help on print the >> real SQL when use with DB.run ? >> > > In order not to block the interpreter, Sequel uses #async_exec and not > #exec on the PG::Connection. Perhaps that's the cause of the problem? Do > you get the same results as Sequel if you use #async_exec on the > PG::Connection (with #block afterward)? > > Thanks, > Jeremy > -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to sequel-talk+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sequel-talk/20e85d33-8744-4517-ab30-2781315ab5b2n%40googlegroups.com.