supsupdev
09/27/2022, 9:15 AMSpoonz
09/27/2022, 12:02 PMlordmike
09/27/2022, 12:18 PMMokamars
09/27/2022, 1:01 PMWaterpile
09/27/2022, 2:15 PMven
09/27/2022, 3:35 PMSteveBrinager
09/27/2022, 3:48 PMtito
09/27/2022, 3:50 PMdwome
09/27/2022, 3:57 PMjfy
09/27/2022, 4:10 PMError querying the database: db error: FATAL: remaining connection slots are reserved for non-replication superuser connections
We're only getting this when we switch from Railway to Supabase. See pic of logs. Any idea why?stevharve
09/27/2022, 4:12 PMsql
BEGIN
IF new.bucket_id != 'team-gallery' THEN
RETURN null;
END IF;
INSERT INTO public.gallery
(object_id, user_id, team_id)
VALUES
(new.id, new.owner, new.path_tokens[0]::uuid);
RETURN new;
END;
While inserting the team_id into the gallery table from the new.path_tokens[0] team_id is null. The object that I am listening for an insert from is in a folder with the uuid of the team.Cheesy
09/27/2022, 5:02 PMSimonP
09/27/2022, 5:20 PMjdgamble555
09/27/2022, 5:22 PMJuicyBenjamin
09/27/2022, 5:47 PMIon
09/27/2022, 6:44 PMsupabase.auth.setAuth(token)
, and the subscriptions in realtime.subscription
table vanish after a few seconds. In logs I found this: "Received an invalid access token from client: {:error, :unknown}" "Unknown connection authorization error: :error"
.
I use the flutter SDK and the jwt is signed using jwt secret and the payload contains all the required claims like for example { "supabase_uid": "1ed9dcf5-e383-4e41-820f-58df106c3e5c", "role": "authenticated", "aud": "authenticated", "app_metadata": {}, "user_metadata": {}, "iss": "my_supabase", "iat": 1663875937, "exp": 1663880737 }
I test my code on a self-hosted supabase and it works as expected.
Can anyone please tell me what can be done in this case?shepherdgames
09/27/2022, 6:46 PMZetiMente
09/27/2022, 6:48 PMselect *
from profiles
INNER JOIN images ON profiles.id = images.profile_id
INNER JOIN follows on profiles.id = follows.following_id
where follower_id = 12;
This works:
let { data: images } = await supabase
.from('images')
.select('*, profiles!inner(*)')
.range(0, 25)
.eq('profiles.id', 10)
.order('created_at', { ascending: false });
But can't figure out the syntax to add follows.following_id. It is a FK to profiles but it's a composite key with followers_id. For some reason can't get a working version of this SQL query into Javascript.NCavaliere1116
09/27/2022, 7:40 PM${process.env.NEXT_PUBLIC_HOST_DOMAIN}/profile
}
)
When the profile page is fetching the user data client side by hitting an api endpoint within the app, the redirect works accordingly.
const { user, error } = useUser()
useEffect(() => {
async function loadData() {
fetch(/api/users/${user?.id}
)
.then(res => res.json())
.then(result => setInfo(result))
}
// Only run query once user is logged in.
if (user) {
try {
loadData()
console.log(user)
} catch (error) {
console.log(error)
}
}
}, [user])
When fetching the data using getServerSideProps, the redirect no longer works and i get sent to the home route of the app. The user is confirmed to be authorized and signed in when navigating back to the /profile page.
export const getServerSideProps = withPageAuth({
async getServerSideProps(ctx) {
const prisma = new PrismaClient()
// Access the user object
const { user, accessToken } = await getUser(ctx)
const prismaUser = await prisma.user.findUnique({
where: {
id: user?.id,
},
})
return {
props: {
user,
prismaUser,
},
}
},
})
Has anyone else experienced this redirect bug when fetching data server side rather than client side? Any help would be greatly appreciated!jdgamble555
09/27/2022, 10:54 PMsql
CREATE OR REPLACE VIEW posts_hearts_count AS
SELECT hearts.pid, posts.*, COUNT(hearts.pid) AS heartsCount
FROM posts
JOIN hearts ON posts.id = hearts.pid
GROUP BY hearts.pid
But I get this error:
Failed to run sql query: column "posts.created_at" must appear in the GROUP BY clause or be used in an aggregate function
I basically want my entire posts data along with the heartsCount
field for the total likes of that post.
Relearning SQL is interesting...
JKevin.
09/27/2022, 10:56 PMNanoBit
09/27/2022, 11:31 PMnkeating
09/28/2022, 12:48 AMsupa_audit
package which looks sufficient, but the issue is we manage authentication outside of supabase so we have an issue of not knowing what user made a specific change to a given record/row...
Whats the best approach to solve this?stevharve
09/28/2022, 2:46 AMDomcario
09/28/2022, 3:35 AMthestepafter
09/28/2022, 4:37 AM49Ryann
09/28/2022, 5:11 AMpsteinroe
09/28/2022, 7:59 AMorganisation-id/entity-id/myfile.jpg
In some cases, we also have one more level, e.g. for conversation with messages, we want to attach files to a message but also query all files of a conversation:
organisation-id/conversation-id/message-id/myfile.jpg
.
To query files for an entity, we use the following query (simplified):
sql
select id
from storage.objects
where bucket_id = 'message_files'
and uuid_from_path_level_2(name) = '7daa4a53-1233-432d-bf11-a9dee8140027'::uuid;
For a better performance, we setup a bunch of indices, and when executed as service_role (bypassing rls), the indices are properly picked up ([Visualised on explain.dalibo](https://explain.dalibo.com/plan/4247g6e82726c139)).cryptoneur
09/28/2022, 8:38 AMmoralis
and clerk
offering some third party soultions as well as someone suggesting to just use wagmi
or rainbowkit
and link a new web3 table to the original users
table via a foreign key.
Anyone has tried any of this? What was your experience? Would love to implement an open source solution but haven't found any good tutorial or codebases. Would love to hear your experience or any links to REPOS where one implemented this!
Thanks 🙏