fix: obtain Postgres URL from branches get command#2996
fix: obtain Postgres URL from branches get command#2996sweatybridge merged 24 commits intosupabase:developfrom yaten2302:develop
Conversation
Signed-off-by: Yaten Dhingra <[email protected]>
|
@sweatybridge , I've a doubt, that as you mentioned in this comment, that a new Also, as you mentioned, that the postgres_url and prostgres_url_non_pooling has to be added if this flag is mentioned with the command and the code can be reused from the |
Signed-off-by: Yaten Dhingra <[email protected]>
|
Hey @sweatybridge , could you please have a look at this PR, I've made the required changes, kindly review and LMK if any more are required!! |
Pull Request Test Coverage Report for Build 12618705729Details
💛 - Coveralls |
Signed-off-by: Yaten Dhingra <[email protected]>
|
Let's do this in smaller steps so I can provide more detailed guidance.
This is how golang works: any variable declared in the same package is shared by all code in that package. Since the output variable is already declared in For your first commit, simply passing it down to branches get command will do. No need to implement the actual behaviour for env output. After you've done that, tag me again so I can check before providing more details for the actual implementation. |
sweatybridge
left a comment
There was a problem hiding this comment.
Feel free to open a new PR if it's easier for you.
|
Also, sorry for the late reply as I was on holiday for the last 2 weeks and there were a lot to catch up on. I will review more promptly this week and next if you plan to make the changes. |
Signed-off-by: Yaten Dhingra <[email protected]>
Signed-off-by: Yaten Dhingra <[email protected]>
|
Heyy @sweatybridge , sorry, actually, I was pushing some changes right now only and that's why didn't see your comment on this PR.
Also, yes, for this, I was also researching about the same and now I understood that, vars are shared across the same package files in Go. |
Signed-off-by: Yaten Dhingra <[email protected]>
Signed-off-by: Yaten Dhingra <[email protected]>
Co-authored-by: Han Qiao <[email protected]>
Co-authored-by: Han Qiao <[email protected]>
Co-authored-by: Han Qiao <[email protected]>
|
Now, how should the Run() func be changed in |
Co-authored-by: Han Qiao <[email protected]>
Signed-off-by: Yaten Dhingra <[email protected]>
Signed-off-by: Yaten Dhingra <[email protected]>
Signed-off-by: Yaten Dhingra <[email protected]>
Signed-off-by: Yaten Dhingra <[email protected]>
Signed-off-by: Yaten Dhingra <[email protected]>
Signed-off-by: Yaten Dhingra <[email protected]>
Signed-off-by: Yaten Dhingra <[email protected]>
internal/branches/get/get.go
Outdated
| |-|-|-|-|-|-|-| | ||
| config := pgconn.Config{ | ||
| Host: utils.GetSupabaseDbHost(resp.JSON200.DbHost), | ||
| Port: uint16(resp.JSON200.DbPort), |
There was a problem hiding this comment.
| Port: uint16(resp.JSON200.DbPort), | |
| Port: uint16(cast.IntToUint(resp.JSON200.DbPort)), |
To fix lint check
There was a problem hiding this comment.
@yaten2302 in case you missed it, there are more linter errors to fix https://github.com/supabase/cli/actions/runs/12608039666
There was a problem hiding this comment.
@sweatybridge , yes, ig I forgot about the linter errors, I've a doubt, that in here, these 2 errors are being show

In the 2nd one, should I remove cast.IntToUInt(...), I think the error is arising because of that only?
For the first one, I've pushed a commit, I think it should be fixed now (formatted the file)
There was a problem hiding this comment.
In the 2nd one, should I remove cast.IntToUInt(...), I think the error is arising because of that only?
We need to implement a new method for safely casting UInt to UInt16 and call it. You can check the existing examples in cast.go on how to check for overflows. But if you feel stuck, I can also take over from here.
There was a problem hiding this comment.
I'll research upon it a and then ask if I encounter any doubts! Also, I wanted to ask that, is it possible to check the linter errors are failing or passing without pushing the changes?
There was a problem hiding this comment.
Hey, I just now pushed a commit to try to fix the linter error, but unfortunately it's failing, could you please guide that is there some other file, in which some issue similar to this is being handled? I would like to understand from that and then try to implement that here.
There was a problem hiding this comment.
// UIntToUInt16 converts a uint to an uint16, handling potential overflow
func UIntToUInt16(value uint) int {
if value <= math.MaxUInt16 {
return uint16(value)
}
return math.MaxUInt16
}
You want to add the above to cast.go and call it like this
Port: cast.UIntToUInt16(cast.IntToUInt(reps.JSON200.Port))
There was a problem hiding this comment.
Oh, okay, got it now, thanks for your help 👍
But, in the first line, shouldn't the return value of the UIntToUInt16 func be uint16?
Signed-off-by: Yaten Dhingra <[email protected]>
Signed-off-by: Yaten Dhingra <[email protected]>
Signed-off-by: Yaten Dhingra <[email protected]>
Signed-off-by: Yaten Dhingra <[email protected]>
|
Thank you so much @sweatybridge for helping me out with this PR, this was my very first contribution with supabase, I'll definitely check out some other issues and work on them 👍 |
What kind of change does this PR introduce?
This PR introduces a new feature to enable users to obtain the Postgres db url from the .env using the
branches getcommand.What is the current behavior?
Fixes #2964
What is the new behavior?
This PR adds a new flag to the
branches getcommand to help users to get the postgres db url from the env.Additional context
Add any other context or screenshots.