postgresql

Ef core 5 many to many filter

十年热恋 提交于 2021-01-28 09:02:05
问题 This is my query public async Task<IEnumerable<Menu>> GetMenuByRolesAsync(string[] roles) { var result= await _context.Menus//.Include(o => o.Parent) .Include(m => m.Childrens) .ThenInclude(m => m.Childrens) .Include(m => m.Roles.Where(r => roles.Contains(r.Name))) --it is not filtering basd on roles .Where(m => m.ParentId == null) .ToListAsync(); } It is generating below query -- @__roles_0='System.String[]' (DbType = Object) SELECT m.id, m.icon, m.name, m.parent_id, m.url, t.role_id, t.menu

How to resolve “Method org.postgresql.jdbc.PgConnection.createBlob() is not yet implemented”

99封情书 提交于 2021-01-28 08:40:32
问题 I have seen posts on how to resolve org.postgresql.jdbc.PgConnection.createClob() is not yet implemented and I have applied spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true as suggested by those posts on the createClob() issue. My issue is I am getting the is not yet implemented message but in reference to the create B lob() method in particular. How do I resolve this for the create B lob() method in particular? Hibernate Core 5.4.20 Postgre 42.2.18 Spring Boot 2.3.3 回答1:

docker-compose postgres restart after running scripts in docker-entrypoint-initdb.d

杀马特。学长 韩版系。学妹 提交于 2021-01-28 08:30:59
问题 I have a simple Docker Compose file to initialize a Postgres DB Instance: version: '3.8' services: my-database: container_name: my-database image: library/postgres:13.1 volumes: - ./db/init-my-database.sql:/docker-entrypoint-initdb.d/init-db-01.sql environment: - POSTGRES_DB=my-database - POSTGRES_USER=admin - POSTGRES_PASSWORD=password ports: - 10040:5432 restart: always networks: - app-network And my script init-my-database.sql looks like this: DROP DATABASE IF EXISTS myschema; CREATE

Postgresql: How to use curl with function

笑着哭i 提交于 2021-01-28 08:20:22
问题 I have a function parse_sdf(text) . When I call the function like this: INSERT INTO test.table("Id", "Test") (SELECT props -> 'Id', props -> 'Test' FROM parse_sdf()); When I execute the INSERT with pgsql I want to pass as a parameter a text file which I download via curl . Like this: INSERT INTO test.table("Id", "Test") (SELECT props -> 'Id', props -> 'Test' FROM parse_sdf('curl http://test/Files/text.txt')); But it doesn't work. Is there a way to accomplish this? UPDATE: Postgres version: 10

postgreSQL query seems to be running on infinite loop

99封情书 提交于 2021-01-28 08:17:47
问题 Following my previous question, I am now trying to remove duplicates from my database. I am first running a sub-query to identify the almost identical records (the only difference would be the index column "id"). My table has roughly 9 million records and the below code had to be interrupted after roughly 1h30 DELETE FROM public."OptionsData" WHERE id NOT IN ( SELECT id FROM ( SELECT DISTINCT ON (asofdate, contract, strike, expiry, type, last, bid, ask, volume, iv, moneyness, underlying,

select statement in postgres function called inside a trigger

╄→гoц情女王★ 提交于 2021-01-28 08:15:15
问题 I'm trying to develop a notification system for the backend of a social media application/website. For now I'm focusing on status updates. What I'm going to do, is putting a trigger on the postgres table that related to status updates so that every time a new status update is posted, a notification is sent to my code. So far I have been able to do that. But an extra feature that I like to implement is extracting all of the people who follow the user who posted the status update, so that I can

how to get dates with postgres

落爺英雄遲暮 提交于 2021-01-28 08:08:44
问题 I was trying to query and return the sum of all records in the last 4 past weeks. I had it working however I while using timestamps. and I am trying to change the precision and and just use dates. briefly instead of timestamp ranges I want just date ranges. this what I had with timestamps. with date_ranges (range_name, range_dates) as ( values ('week_0', tstzrange ((now()-interval '6 days'), now(),'[]')) , ('week_1', tstzrange ((now()-interval '13 days'), (now()-interval '7 days'), '[]')) , (

Why is pg_restore segfaulting in Docker?

时光毁灭记忆、已成空白 提交于 2021-01-28 07:59:35
问题 I am testing a backup/restore procedure for my postgres DB inside a docker container. I dump my db like this: $ docker exec -ti my_postgres_container pg_dump -Fc -U postgres > db.dump Afterwards, I try to restore it like this: $ docker cp db.dump my_postgres_container:/db.dump $ docker exec -ti my_postgres_container pg_restore -U postgres -c -d postgres db.dump The command returns without output or errors, but nothing happens. So instead, I tried to restore it manually like this: $ docker cp

Regex pattern matching with pg_trgm (trigram matching)

点点圈 提交于 2021-01-28 07:44:09
问题 I have a database in postgresql called mydata with a field called text. I'm interested in doing regex pattern matching and only returning the snippet of the match, not the entire text. I know you can use pg_trgm (creates a trigram matching index) to speed up the search, but is there a way to do both the searching and matching as a combined statement? I'll provide some context: CREATE EXTENSION pg_trgm; CREATE INDEX text_trgm_idx ON mydata USING GIN(text gin_trgm_ops); I'll use the example

Other way to cast varbit to int? And bigint?

半腔热情 提交于 2021-01-28 07:31:46
问题 This function is a workaround ... nothing with better performance ? CREATE or REPLACE FUNCTION varbit_to_int(v varbit) RETURNS int AS $f$ SELECT CASE bit_length(v) WHEN 1 THEN v::bit(1)::int WHEN 2 THEN v::bit(2)::int WHEN 3 THEN v::bit(3)::int ... WHEN 30 THEN v::bit(30)::int WHEN 31 THEN v::bit(31)::int WHEN 32 THEN v::bit(32)::int ELSE NULL::int END $f$ LANGUAGE SQL IMMUTABLE; Same problem for bigint: CREATE or replace FUNCTION varbit_to_bigint(p varbit) RETURNS bigint AS $f$ SELECT CASE